Re: Forwarding key events to a non first responder?
Re: Forwarding key events to a non first responder?
- Subject: Re: Forwarding key events to a non first responder?
- From: "John C. Randolph" <email@hidden>
- Date: Wed, 12 Jun 2002 16:34:04 -0700
On Tuesday, June 11, 2002, at 09:58 PM, Dan Wood wrote:
>
The subject line probably doesn't explain my question well
>
enough. Essentially what I'd like to do is have a big
>
NSTableView on a window that may or may not actually be first
>
responder -- perhaps there are some buttons or text fields on
>
the window. I'd like to be able to have keys that are
>
interesting to the NSTableView -- e.g. up/down arrows, page up &
>
page down -- essentially "forwarded" to the NSTableView, even if
>
something else is actually first responder. That would make it
>
much more intuitive for somebody to make use of the window, not
>
having to "tab into" the table (especially useless since there
>
is no highlighting shown when the table is first responder.
>
>
Any suggestions to accomplish this somewhat gracefully?
I've seen some pretty elaborate ideas laid out in this thread,
but you should be able to do what you want w/r/t passing events
around without resorting to any tricky hacks with the Obj-C
runtime.
If you just want to intercept event dispatching, you can
subclass NSWindow, and override -sendEvent:.
eg:
@implementation MyWindow
- sendEvent:(NSEvent *) theEvent
{
if ([theEvent type] == NSKeyDown)
switch ([[theEvent characters] characterAtIndex:0])
{
case NSUpArrowFunctionKey:
case NSDownArrowFunctionKey:
case NSLeftArrowFunctionKey:
case NSRightArrowFunctionKey:
[tableView keyDown:theEvent];
return;
...
}
[super sendEvent:theEvent];
}
-jcr
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
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.