Re: Trouble making a table become first responder in key loop
Re: Trouble making a table become first responder in key loop
- Subject: Re: Trouble making a table become first responder in key loop
- From: Jason Harris <email@hidden>
- Date: Sat, 09 Nov 2002 02:52:32 -0700
Hi List,
I was wondering whether anyone has managed to resolve this (old) issue. I'm
running across the same thing.
When trying to switch focus (using tab) into an NSTableView, I'm getting
nextValidKeyView equal to nil, so the 'tab' has no effect. The NSTableView
returns YES for both acceptsFirstResponder and becomeFirstResponder.
Any insight?
Jason Harris
Geekspiff
>
Hi all,
>
>
Here is a bit of an issue.
>
>
I have three views in my keyboard loop: two NSTableViews and a custom
>
NSView subclass.
>
>
If either of the NSTableViews has focus (e.g. after a mouse click),
>
pressing tab will correctly cause its nextKeyView to take focus.
>
However, I am having trouble making the NSTableViews receive focus after
>
hitting tab in my custom view.
>
>
Here's keyDown in my custom view:
>
>
- (void) keyDown: (NSEvent*)event
>
{
>
if ([[event characters] isEqualToString:@"\t"])
>
[[self window] selectNextKeyView:self];
>
}
>
>
Pretty simple, and I would expect it to work, but it doesn't (nothing
>
happens). Adding some diagnostic code into that if clause reveals the
>
following when I press tab:
>
>
2002-05-28 12:37:26.743 Doggiebox[2385] [self nextKeyView]: <NSTableView:
>
0x269bf0>
>
2002-05-28 12:37:26.744 Doggiebox[2385] [[self nextKeyView]
>
acceptsFirstResponder]: 1
>
2002-05-28 12:37:26.744 Doggiebox[2385] [self nextValidKeyView]: (null)
>
>
This tells me that my custom view's nextKeyView is an NSTableView (good),
>
and that it will accept first responder (good). However,
>
nextValidKeyView is null! It should be the same NSTableView reported as
>
nextKeyView, no? I don't understand why this is. According to the doc
>
for -[NSView nextValidKeyView]:
>
>
> Returns the closest view object in the key view loop that follows the
>
> receiver and actually accepts first responder status, or nil if there is
>
none.
>
>
Clearly my keyboard loop is failing because my custom view is not
>
returning a nextValidKeyView, but why is this the case? It must be
>
something to do with NSTableView -- if I substitute an NSTextField as the
>
nextKeyView, it works.
>
>
-ben
_______________________________________________
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.