Re: next TextField with Enter key
Re: next TextField with Enter key
- Subject: Re: next TextField with Enter key
- From: Thom Meijer <email@hidden>
- Date: Fri, 7 Oct 2005 02:00:38 +0200
Thanks for the suggestion! Unfortunately I'm not able to make it work.
I subclassed NSTextField, put
-(void)keyDown:(NSEvent*)event
{
if ([[event characters] isEqualToString:@"\r"])
[[self window] selectNextKeyView:self];
}
inside. This seems not to work because the keyDown is captured by the field
editor (duh?).
Then, I tried to make IBAction in myController for text field with
{
[[nextField window] makeKeyAndOrderFront:self];
[[nextField selectText:self];
}
inside. This also doesn't work. I don't know why. (Btw, I got this from
Currency converter tutorial)
Or, IBAction with different code:
{
[[currentField window] selectNextKeyView:currentField];
}
This also doesn't work. (currentField and nextField are outlets to my text
fields)
Oh, anyone willing to share any more suggestions, please?
Isn't it just possible to trigger Tab-down event on filling-in text field?
Something like the above-mentioned IBAction of text field with <somehow
force the app to think the Tab key was pressed>?
Thank you in advance...
next TextField with Enter key
Hello there!
I have few text fields and I know how to jump between them with Tab key and
Shift-Tab. That is, in IB, just control-drag from the current one to the
following, connect nextKeyView outlet and that's it. But how can I achieve
similiar behavior with Enter key? Preferably also in IB?
I read http://lists.apple.com/archives/cocoa-dev/2005/Sep/msg01208.html-(IBAction)yourButtonAction:(id)sender
{
[[sender window] makeFirstResponder:[sender nextValidKeyView]];
}
but somehow it doesn't work for me. I know that yourButtonAction is called
when I hit enter but it doesn't advance to next field.
Thanks for any suggestions.
On 10/6/05, SA Dev <email@hidden> wrote:
>
> Thom:
>
> You'll probably have to subclass NSTextField and override -
> keyDown: and catch the return key and call your nextValidKeyView line
> from there.
>
> Hope this helps.
>
> - SADev
>
>
> On Oct 6, 2005, at 3:30 PM, Thom Meijer wrote:
>
> > Hello there!
> >
> > I have a few text fields and I know how to jump between them with
> > Tab key
> > and Shift-Tab. That is, in IB, just control-drag from the current
> > one to the
> > following, connect nextKeyView outlet and that's it. But how can I
> > achieve
> > similiar behavior with Enter key? Preferably also in IB?
> >
> > I read http://lists.apple.com/archives/cocoa-dev/2005/Sep/
> > msg01208.html
> >
> > - (IBAction)yourButtonAction:(id)sender
> > {
> > [[sender window] makeFirstResponder:[sender nextValidKeyView]];
> > }
> >
> > but somehow it doesn't work for me. I know that yourButtonAction is
> > called
> > when I hit enter but it doesn't advance to next field.
> >
> > Thanks for any suggestions.
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Cocoa-dev mailing list (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> > 40silentalcove.net <http://40silentalcove.net>
> >
> > This email sent to email@hidden
> >
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden