Clarifying when NSTextField/Cell triggers target/action...
Clarifying when NSTextField/Cell triggers target/action...
- Subject: Clarifying when NSTextField/Cell triggers target/action...
- From: George Orthwein <email@hidden>
- Date: Thu, 14 Jun 2007 15:22:14 -0400
I'm sort of surprised by the behavior I'm seeing so I just want to
verify that it is correct...
NSTextFields:
I'm only seeing them trigger the action when pressing Return or
Enter. Editing and hitting tab allows a new value without triggering
the action. This seems to contradict the docs:
"By default, text fields send their action message when editing ends
—that is, when the user presses Return or moves focus to another
control."
http://developer.apple.com/documentation/Cocoa/Conceptual/
TextArchitecture/Concepts/TextFieldsAndViews.html#//apple_ref/doc/uid/
20001799-50110
However, the NSTextField reference listing for textDidEndEditing does
seem to say action is only sent with Return (and we assume Enter as
well?):
If the user ended editing by pressing Return, this method tries to
send the receiver’s action to its target; if unsuccessful, it sends
performKeyEquivalent: to its NSView (for example, to handle the
default button on a panel); if that also fails, the receiver simply
selects its text.
If the user ended editing by pressing Tab or Shift-Tab, the
receiver tries to have its NSWindow object select its next or
previous key view, using the NSWindow method
selectKeyViewFollowingView: or selectKeyViewPrecedingView:. If
unsuccessful in doing this, the receiver simply selects its text.
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/Classes/NSTextField_Class/Reference/Reference.html#//
apple_ref/occ/instm/NSTextField/textDidEndEditing:
NSTextFieldCells in a tableview:
It appears that clicking on the cell will trigger the action, while
editing and updating the value does not. So you can tab in, change
the value and tab/return/enter out and not trigger the action.
I would like to trigger the action whenever an edit happens. I assume
I need to use textDidEndEditing and trigger the action (and perhaps
nicely filter out NSCancelTextMovement)?
I would think this would come up a lot (as the default mechanism
seems... well, somewhat useless) but I'm not seeing it mentioned
despite a long search of the archives. I guess I just expected it to
be tied to editing which it decidedly is not. The differing behavior
of fields and cells also threw me (click vs return/enter).
Just wondering if I'm missing something. Any confirmations/
clarifications very welcome.
Thanks!
George
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden