• 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: Cocoa keyboard input
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa keyboard input


  • Subject: Re: Cocoa keyboard input
  • From: Michael Hopkins <email@hidden>
  • Date: Tue, 25 May 2010 10:38:29 -0700

John,

It seems that you have a fundamental misunderstanding about how events work in Cocoa on Mac OS X. I will do my best to explain to, provide relevant documentation links, and answer your questions as best as possible.

In Mac OS X, events are processed by the application object (the host you are running in), and are dispatched according to the event type. Mouse events go first to the window, and then are dispatched to the view in which the click occurred. Key events go to the first responder of the key window:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/EventOverview/Introduction/Introduction.html#//apple_ref/doc/uid/10000060i

Futhermore, key events are processed based on whether the key is a character, a key equivalent, keyboard action, etc. Some events such as command keys are intercepted by the global application object (in your host). Some keys may be intercepted at that level and never reach your plugin because they have special meaning to your host (such as the space key being used to control the hosts' transport). You cannot rely on which command keys are available to your plugin since this behavior is dictated by your host and what key bindings are defined.

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/HandlingKeyEvents.html#//apple_ref/doc/uid/10000060i-CH7-SW1

Now, this special key-processing caveat aside, key events will get delivered to your plugin view if the window that your view is in has focus. In this case, key events are sent to the first responder of that window. If your view is not the first responder of the window, you will not get any key events.

How does your view become first responder? Any textfields that are in your AudioUnit view will automatically respond correctly. Once they are clicked in, they become first responder, and then key events are delivered directly to them. If you have custom objects that you expect to handle key events, then they need to be a subclass of NSResponder, and need to acceptFirstResponder events by overriding -acceptsFirstResponder and returning YES. Secondly, if you have your own mouseDown: handler, you need to make sure that clicking on your view sets the first responder of the window to your object:

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSResponder_Class/Reference/Reference.html#//apple_ref/occ/cl/NSResponder

If you do not do these things correctly, you will not receive any key events. I realize this is a lengthly response, but I feel that it is important to answer as completely as possible to avoid any further confusion on this topic. So, the answer to your question is:

A) You (probably) did not code your view right.

Key events work just fine in logic and other hosts, with the caveat that there are some special keys that those hosts may pre-process and may or may not deliver to you. This behavior really is up to the host, and you should not try to circumvent the event system of the host that you are living in.

If you have any further questions on this topic, I would be more than happy to answer!

Best of luck to your in your plugin development.

-michael

On May 25, 2010, at 6:31 AM, john smith wrote:

 

 
>So, we seem to have settled that Logic and AULab is not passing on the keyboard events to the plug-ins.

>i'm not sure we've "settled" this at all. i would be very, very suprised if you can't get logic (at least) to forward key events to a plugin view.
If we havn't settled on this, then my original question remains, I'm afraid: How do I receive keyboard input from Logic? Currently my breakpoints are not triggered, which means that
 
A: I didn't code it right
 
or
 
B: I have to change some Logic setting or something like that
 
or
 
C: Logic does not support keyboard input in the plug-ins
 
 
 
Thanks,
 
 
Michael Olsen

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • RE: Cocoa keyboard input
      • From: john smith <email@hidden>
    • Re: Cocoa keyboard input
      • From: Michael Hopkins <email@hidden>
    • Re: Cocoa keyboard input
      • From: Paul Davis <email@hidden>
References: 
 >forwarding key events to cocoa plugin views (From: Paul Davis <email@hidden>)
 >Cocoa keyboard input (From: john smith <email@hidden>)
 >Re: Cocoa keyboard input (From: Paul Davis <email@hidden>)
 >RE: Cocoa keyboard input (From: john smith <email@hidden>)
 >Re: Cocoa keyboard input (From: Paul Davis <email@hidden>)
 >RE: Cocoa keyboard input (From: john smith <email@hidden>)

  • Prev by Date: Re: AudioQueue getting delayed by other audio output of the system
  • Next by Date: Re: Cocoa keyboard input
  • Previous by thread: Re: Cocoa keyboard input
  • Next by thread: Re: Cocoa keyboard input
  • Index(es):
    • Date
    • Thread