« Return to Thread: Handling ui feedback loops

Re: Handling ui feedback loops

by Andreas Raab :: Rate this Message:

Reply to Author | View in Thread

 > Whats the proper pattern for this use of tweak fields and input fields?

You'll have to guard manually, e.g., instead of either

MyInputField>>onModelValueChanged
     <on: valueChanged in: model>
     self value := model value asString.

MyInputField>>onValueChanged
     <on: valueChanged>
     model value := Number readFrom: self value.

(which may loop) use either one of:

MyInputField>>onModelValueChanged
     <on: valueChanged in: model>
     newValue := model value asString.
     newValue = value ifFalse:[
         self value := newValue.
     ].

MyInputField>>onValueChanged
     <on: valueChanged>
     newValue := Number readFrom: self value.
     newValue = model value ifFalse:[
         model value := newValue.
     ].

Cheers,
   - Andreas

Steven W. Riggins wrote:

> I have a input field and when I change the value of the tweak field, its
> mirrored into the field.  I also use this field as a input field, so I
> want to know when the value changed, and update my model.  Problem is, I
> set the field, I get a changed event, I convert the field string gto a
> number, set my model, which updates the field, and around and around I go.
>
> propertyValueAt: key put: newValue with: changeEvent
>     "Store the value of my property at key"
>     | oldValue |
>     myProperties ifNil:[myProperties := IdentityDictionary new].
>     oldValue := myProperties atProperty: key put: newValue.
>     oldValue == newValue ifTrue:[^newValue].
>     self signalChanged: changeEvent from: oldValue to: newValue.
>     ^newValue
>
> Does ==, which fails because '123' == (123 asString) fails.
>
> WHats the proper pattern for this use of tweak fields and input fields?
> _______________________________________________
> Tweak mailing list
> Tweak@...
> http://impara.de/mailman/listinfo/tweak
>
>
_______________________________________________
Tweak mailing list
Tweak@...
http://impara.de/mailman/listinfo/tweak

 « Return to Thread: Handling ui feedback loops