Re: [newbie] /r invoking button instead of going to textfield?
Re: [newbie] /r invoking button instead of going to textfield?
- Subject: Re: [newbie] /r invoking button instead of going to textfield?
- From: Ando Sonenblick <email@hidden>
- Date: Sun, 15 Sep 2002 14:32:30 -0700
Ondra,
Thanks for the tip. Unfortunately it has identified another issue I have.
I actually have three text fields in the window; I've hooked all three up to
the button as you suggest and the button now does indeed get triggered on a
return key event in all three of my text fields. Thanks.
However, in the method that gets called by the button, I am using the
currentEditor method to determine which of the three edit fields is the
current one:
- (IBAction) convert: (id) sender
{
if ([binaryTextFieldOutlet currentEditor] != nil)
[self performBinarySourceConversion];
if ([decimalTextFieldOutlet currentEditor] != nil)
[self performDecimalSourceConversion];
if ([hexTextFieldOutlet currentEditor] != nil)
[self performHexSourceConversion];
}
This works fine when the button is triggered via the mouse; but not when via
the return key.
Instead, none of the text fields is the currentEditor. I'll look into what
I can do about this, but perhaps you know of a better way to determine the
current text field of a window?
I have tried getting the first responder of the window, and even when one of
my text fields is the first responder, I instead get back a pointer to an
NSTextView and not an NSTextField.... And I don't know yet how to match
the two.
Any suggestions you may have are very appreciated.
Thx,
Ando
>
>
On Sunday, September 15, 2002, at 10:18 , Ando Sonenblick wrote:
>
>
> I have a window with an NSTextField and an NSButton in it. The button is
>
> set to have return activate it. However, with the NSTextField as the
>
> first
>
> responder it "eats" any return key presses.
>
>
Just link the text field target to the button's performClick:
>
>
> So how do I make it so that the return key activates the button no matter
>
> who else may be the first responder?
>
>
Generally it should not be done of course: presume the FR was a text view,
>
and the user then could not finish a line? Whew!
>
---
>
Ondra Cada
>
OCSoftware: email@hidden http://www.ocs.cz
>
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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.