Trouble making a table become first responder in key loop
Trouble making a table become first responder in key loop
- Subject: Trouble making a table become first responder in key loop
- From: Ben Kennedy <email@hidden>
- Date: Tue, 28 May 2002 12:48:17 -0400
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
--
Ben Kennedy, chief magician
zygoat creative technical services
613-228-3392 | 1-866-466-4628
http://www.zygoat.ca
_______________________________________________
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.