Re: Tracking changes of first responder
Re: Tracking changes of first responder
- Subject: Re: Tracking changes of first responder
- From: Nicko van Someren <email@hidden>
- Date: Tue, 13 Jul 2004 15:05:19 +0100
On 13 Jul 2004, at 14:05, Matthew Weinstein wrote:
I've run into a strange problem with handling an NSTextField which has
an action associated with it. The action was intended to be called
when the user filled in some text and hit return. HOWEVER, the action
also seems to be called if the NSTextField loses first responder
status, i.e., if the user clicks on the NSTextView in the window or a
NSTableView in the window. So I'm thinking I need a flag or something
when the first responder status changes that signals the action to do
nothing (but reset the flag) in that case.
The problem is I can't seem to find a delegate method or notification
that goes with changes of firstresponder status... Help!
Must be there (i would guess)
If you're using Interface Builder you can choose the Send action on:
Enter Only radio button on the attributes of the NSTextField.
If you are not using Interface Builder then...
Inside your NSTextField there is is an NSTextFieldCell; you can get
this by calling the -cell method inherited from NSControl. On the
NSTextFieldCell you can call the NSCell inherited method
-(void)setSendsActionOnEndEditing:(BOOL)flag which is defined as:
Sets whether the receivers NSControl object sends its action message
whenever the user finishes editing the cells text. If flag is YES, the
receivers NSControl object sends its action message when the user does
one of the following:
Presses the Return key
Presses the Tab key to move out of the field
Clicks another text field
If flag is NO, the cells NSControl object sends its action message
only when the user presses the Return key.
I hope this helps.
Nicko
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.