« Return to Thread: Handling ui feedback loops

Re: Handling ui feedback loops

by Andreas Raab :: Rate this Message:

Reply to Author | View in Thread

Steven W. Riggins wrote:
> I suppose, I have a multiple selections, so multiple models to check
> against, so the loop could go through twice.
>
> I'd rather get a differtent signal when the user made an edit, opposed
> to any old value change.  In other words, anything else modifying the UI
> to get a model change is a broken pattern.  I really only want to know
> when the field changes due to a direct user action.

Ah. In this case use the #accept event for an input field. This will be
signaled if the user accepts the input manually (e.g., upon hitting
enter/return).

Cheers,
   - Andreas

>
> On Aug 17, 2006, at 8:22 PM, Andreas Raab wrote:
>
>> > 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
>>
>
> _______________________________________________
> 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