GtkTextView input validation difficulty -- paste operation not atomic




Our applications use GtkTextView widgets with diverse input validation
requirements.  Some restrict input to numeric digits only, others have
length limits and other limits.  The validation is done with callbacks on
the "insert-text" signal, rejecting any input that is invalid.  This has
worked well in many cases but I recently discovered that pasting text over
other highlighted text was producing incorrect results.  The problem turned
out to be that paste operations are not atomic but are implemented as first
an insertion of the pasted-in text, then deletion of the text that was
highlighted before the paste began.  The result was that the "insert-text"
callback first received the intermediate result prior to receiving the final
result after the deletion, thus leading to incorrect rejection of the input
at the first call.  I changed it to use the "changed" signal instead but the
same intermediate result still is received first by the callback.  In either
case this could work if the callback could detect that it was in the middle
of a paste operation and therefore defer validation until the deletion step
of the paste was completed but I see no way to do that.  How can that be
done?  Or is there some completely different way to do validation?

JBoncek Hunter Com
-- 
View this message in context: 
http://www.nabble.com/GtkTextView-input-validation-difficulty----paste-operation-not-atomic-tf2419467.html#a6745244
Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]