Re: setting nextKeyView
Re: setting nextKeyView
- Subject: Re: setting nextKeyView
- From: Esteban Uribe <email@hidden>
- Date: Fri, 8 Nov 2002 17:05:28 -0800
Hi Marco,
I had somewhat the same problem until i finally figured out the
"correct" way to do this.
You need to call the view's window's selectKeyViewFollowingView and
selectPreviousKeyView
otherwise i think it will skip some views even if you set them to be
the next keyviews.
the following code snippet should help :)
IBOutlet NSButton *button;
....
- (BOOL)textView:(NSTextView *)aTextView
doCommandBySelector:(SEL)aSelector
{
NSEvent *theEvent = [NSApp currentEvent];
unichar keyDownCharacter = [[theEvent charactersIgnoringModifiers]
characterAtIndex:0];
//this should select the next view when tab character is hit
if (keyDownCharacter == NSTabCharacter) {
[[aTextView window] selectKeyViewFollowingView:aTextView];
}
//notice the backtab is equivalent to the shift-tab which should
select the previous view
else if(keyDownCharacter == NSBackTabCharacter) {
[[aTextView window] selectPreviousKeyView:aTextView];
}
//detect if enter key was pressed (does not detect return key)
else if (keyDownCharacter == NSEnterCharacter) {
//pixie magic that sends enter key to the NSButton we want :-)
[button performKeyEquivalent:[NSEvent keyEventWithType:NSKeyDown
location:NSMakePoint(0,0) modifierFlags:[button
keyEquivalentModifierMask] timestamp:0 windowNumber:0 context:nil
characters:[button keyEquivalent] charactersIgnoringModifiers:[button
keyEquivalent] isARepeat:NO keyCode:0]];
}
else {
return NO;
}
return YES;
}
Hope this helps :)
-Esteban
On Friday, November 8, 2002, at 10:20 AM, Marco Binder wrote:
Hi everyone,
I have a NSTextView and I want Tab to actually end editing and jump to
the next view. I intercept tab using - (BOOL)
textView:doCommandBySelector: which works fine. calling [myTextView
nextKeyView] on the passed NSTextView always gives me an NSScroller...
I ve set the outlet "nextKeyView" in IB as well as programatically
with the same result. I DID set theoutlet for the NSTextView, not for
the enclosing NSScrollView (doing that hasnt helped me either).
So, what is the problem? Can anyone help me?
Of course I can still manually pass the right view for each
makeFirstResponder message, but this is a hassel and includes some
if-statements... And it reduces the reusability to zreo.
marco
--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
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.