Found a little bug in the handling of invalid formats by a TextEdit
(5.0.3). If one types in garbage such that the typeconverter signals InvalidFormat during the execution of #convertFromRightToLeft: then the ValueConvertingControlView>>updateModel method beeps and forces the null value (such as nil) into the model with a "self value: self typeconverter leftNullValue". So far so good. If the model previously had some other value, then putting in the null value triggers notification of the change and the textEdit ends up displaying the rightNullValue (e.g. blank). But, if the model already had the null value, then the notification doesn't occur, and the textEdit gets left with the typed in garbage (as an "alternate" representation of the rightNullValue). :-( This was happening in updatePerChar mode, but seems like it might also occur without that. My hacked in fix was to put a "self refreshContents" at the end of the exception handling in ValueConvertingControlView>>updateModel. Probably not the right fix, but it seems to be doing the job. Any thoughts? regards, -Bill ------------------------------------------- Bill Dargel [hidden email] Shoshana Technologies 100 West Joy Road, Ann Arbor, MI 48105 USA |
In playing with this some more, I found that I really wanted to do the
#refreshContents for the mainline case as well as the exception. I've ended up using the method as shown below. If a typeconverter maps a number of input variants into a single 'canonical' form, it seems that always displaying that form is good feedback for the user. What do others think? regards -Bill --------------------------- !ValueConvertingControlView methodsFor! updateModel "Private - The displayed value of the receiver has changed so set this back into the model after first running through the type converter" "wod - add a #refreshContents to force the display value to be a 'canonical' representation of the model" [self model value: (self typeconverter convertFromRightToLeft: self displayValue)] on: InvalidFormat do: [:exception | exception beep. self value: self typeconverter leftNullValue]. self refreshContents. "<--- wod added" self invalidateUserInterface! ! !ValueConvertingControlView categoriesFor: #updateModel!private!updating! ! ---------------------------------- Bill Dargel wrote: > Found a little bug in the handling of invalid formats by a TextEdit > (5.0.3). > > If one types in garbage such that the typeconverter signals > InvalidFormat during the execution of #convertFromRightToLeft: then the > ValueConvertingControlView>>updateModel method beeps and forces the null > value (such as nil) into the model with a "self value: self > typeconverter leftNullValue". So far so good. If the model previously > had some other value, then putting in the null value triggers > notification of the change and the textEdit ends up displaying the > rightNullValue (e.g. blank). But, if the model already had the null > value, then the notification doesn't occur, and the textEdit gets left > with the typed in garbage (as an "alternate" representation of the > rightNullValue). :-( This was happening in updatePerChar mode, but seems > like it might also occur without that. > > My hacked in fix was to put a "self refreshContents" at the end of the > exception handling in ValueConvertingControlView>>updateModel. Probably > not the right fix, but it seems to be doing the job. Any thoughts? > > regards, > -Bill ------------------------------------------- Bill Dargel [hidden email] Shoshana Technologies 100 West Joy Road, Ann Arbor, MI 48105 USA |
Free forum by Nabble | Edit this page |