Key Commands and How to Listen for them

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

  1. macrumors newbie

    Joined:
    Oct 13, 2010
    #1
    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?

    Thanks,
    DeviledMoon
     
  2. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    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. thread starter macrumors newbie

    Joined:
    Oct 13, 2010
    #3
    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