Discussion:
Handling ui feedback loops
Steven W. Riggins
2006-08-18 01:33:17 UTC
Permalink
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?
Andreas Raab
2006-08-18 03:22:33 UTC
Permalink
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
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
http://impara.de/mailman/listinfo/tweak
Steven W. Riggins
2006-08-18 04:24:41 UTC
Permalink
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.
Post by Steven W. Riggins
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.
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
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
http://impara.de/mailman/listinfo/tweak
_______________________________________________
Tweak mailing list
http://impara.de/mailman/listinfo/tweak
Andreas Raab
2006-08-18 04:46:33 UTC
Permalink
Post by Steven W. Riggins
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
Post by Steven W. Riggins
Post by Andreas Raab
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.
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
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
http://impara.de/mailman/listinfo/tweak
_______________________________________________
Tweak mailing list
http://impara.de/mailman/listinfo/tweak
_______________________________________________
Tweak mailing list
http://impara.de/mailman/listinfo/tweak
Loading...