I would like to validate the contents of an NSTextFieldCell in a table when the user has finished editing it.
I think I know of 2 methods to do it, they both work for a regular NSTextField outside a table, but I can’t get any of the methods to work for a text field in a table.
The NSTextFieldCell is in a table column in a document-based application.
An array controller manages the values, and that one works.
The NSTextFieldCell’s attribute for Action is set to “Send On End of Editing” (in IB).
Method 1 is a simple bindings method, where I simply bind the NSTextFieldCell to a method (my defined applescript handler) in the File’s Owner.
I can get this to work beautifully for an NSTextFieldCell in a standard NSTextField in the window, but I cannot get it to work for the NSTextFieldCell that is inside a table.
Method 2 is by code. In this case, the NSTextFieldCell is first bound to an outlet in File’s owner via a property thus:
[b]property theTextField : missing value[/b] --bound as an outlet to the NSTextFieldCell in IB
In the code I then explicitly set the action method:
[b]theTextField's setAction_("theValidation:")[/b] --this is in the documentation for NSActionCell, "theValidation:" is a selector.
My expectation is that the following handler would be called after editing the text field in the table:
on theValidation_(sender)
display dialog “works”
end theValidation_
The Xcode documentation says that target by default is set to nil to allow it to be determined at run time. That should be ok for me, but I also tried to set it:
theTextField’s setTarget_(me)
But that did not solve anything.
What am I doing wrong, or misunderstand?
It is as if the table or array controller stops this from working, since it works for a regular NSTextField (outside the table)
PS: the prefix “the” in the property and handler names is actually something different in the real code, I just cleaned it from unnecessary clutter.