When I send stringValue
to a NSTextField
when it's field editor is active, it returns the current value from the field editor. But I need the original value from the NSTextField
before it started editing! How can I get it? (tried to get the stringValue
from the NSTextFieldCell
, but I get the field editors value too)
Any suggestions how I can get the original value?
views:
100answers:
1
A:
You shouldn't ask the text field for its value, you should obtain the value from the model object that the text field represents.
Never store model data in a view. You should store it in a model object which is linked to the view through some sort of controller.
Rob Keniger
2010-01-07 08:43:08
you're definitely right! The reason why I try to get that value is, that I wan't to make a TextField that only set's a new value if the old value is not the same. When I call setStringValue: and the original value of the field is the same as the new value, I don't want to overwrite the value because that changes the value in the field editor too. To test that in the model I need to do it every time before I set the value of the TextField and that's not comfortable at all.
V1ru8
2010-01-07 08:51:52