• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Forwarding key events to a non first responder?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Forwarding key events to a non first responder?
      • From: Marco Scheurer <email@hidden>
References: 
 >Forwarding key events to a non first responder? (From: Dan Wood <email@hidden>)

  • Prev by Date: Re: -[NSResponder flagsChanged:] not called?
  • Next by Date: Cocoa/Java - How to get files dropped onto app from Finder
  • Previous by thread: Re: Forwarding key events to a non first responder?
  • Next by thread: Re: Forwarding key events to a non first responder?
  • Index(es):
    • Date
    • Thread