Key Commands and How to Listen for them

Discussion in 'Mac Programming' started by DeviledMoon, Oct 22, 2010.

  1. DeviledMoon macrumors newbie

    Oct 13, 2010
    Hey Guys,

    Just wondering, lets say i want to connect the function (OpenApple+Fn+1) to load a menu item.

    How abouts would i go about listening for the command and or listening for menu item clicks

    i know it has to all be linked, but how would i listen for the commands?

  2. HiRez macrumors 603


    Jan 6, 2004
    Western US
    Assuming you are using Cocoa + Obj-C, if it's assigned to a menu item, just set the item to that key sequence in Interface Builder and set the action of the menu item to call your method in your code, or use nil-targeted action if it's a multi-document app (in this case connect the item to the First Responder object). The event system will traverse the responder chain until it finds something that implements the method whose name matches the one you set in IB.
  3. DeviledMoon thread starter macrumors newbie

    Oct 13, 2010
    so in general, i need to setup an Output/function to load what i want it to do, and link that menu item to it?

Share This Page