Re: NSTextField changing first responder on return key not working
Re: NSTextField changing first responder on return key not working
- Subject: Re: NSTextField changing first responder on return key not working
- From: Tod Cunningham <email@hidden>
- Date: Tue, 20 Jul 2004 02:12:21 -0400
Matt:
Thanks for your advice, it worked like champ. I did the following:
// Can you say HACK... I want an "add" button to respond to the return
key automatically. However,
// if I setup the button key equivelent to '\r' then both the textfield
and button will try
// to respond to the return key. Both actions will be completed, but
the textfield will maintain
// focus. It looks like part of the return key action on a field is to
set focus back to the field.
// This is fine, except after an add I want to clear the fields and set
the focus back to the
// first one. You see this flicker from the first one back to the
field that currently has focus.
// I do the following to HACK around this:
//
// 1. Set key equivalent on button to CMD-\r. This will allow button
to be blue and blink.
// 2. This routine will send a perfom client event to the button when
return is pressed.
//
- (void)keyUp:(NSEvent *)theEvent
{
unichar theCharacter = [[theEvent characters] characterAtIndex:0];
if( theCharacter == '\r' )
[addButton performClick:[self window]];
}
- Tod
On Jul 19, 2004, at 8:25 PM, matt neuburg wrote:
On Sun, 18 Jul 2004 22:19:31 -0400, Tod Cunningham <email@hidden>
said:
I have a very simple window with a couple of text fields and a button.
The button is set with a key equivalent of return. When the return
key
is pressed (via the button connection) I clear the text fields and
want
to put the first responder back to the 1st text field. When I do this
by pushing the button with the mouse it works great. However, when I
press return the focus briefly changes to the 1st field (long enough
for me to see the focus ring) and then it goes back to whichever field
I pushed the return button in. Any ideas on what is going on?
What I do is implement control:textView:doCommandBySelector and "hit"
the
button myself by sending it performClick:. m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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.
_______________________________________________
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.