Setting hotkey using RegisterEventHotKey

Discussion in 'Mac Programming' started by ruhi, Aug 7, 2009.

  1. ruhi macrumors member

    Joined:
    Jun 17, 2009
    #1
    Hello All,

    I have registered a hot key using:

    RegisterEventHotKey(49,cmdKey + shiftKey , myHotKeyID, GetApplicationEventTarget(), 0, &myHotKeyRef);

    here the modifiers are written as cmdKey + shiftKey.

    Now i have taken my NSTextField subclass which is trapping hotkey pressed on it. Now i want to register this new hot key.

    But problem is that i have the new hot key as nsstring like @"cmd shift R"

    How can i give this combination in:

    RegisterEventHotKey(49,cmdKey + shiftKey , myHotKeyID, GetApplicationEventTarget(), 0, &myHotKeyRef);

    as the type is UInt32. Do i have to look for each and every combination possible? Is there any other way to save hotkey or register hotkey ??
    :confused::(


    Thanks,
    Ruhi.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Is this for a Carbon app? If not, I'd suggest going about it another way since Carbon is practically obsolete and shouldn't be used for new development. This is one way to do it in Cocoa, although that's an old post.
     
  3. ruhi thread starter macrumors member

    Joined:
    Jun 17, 2009
    #3
    Setting hotkey using RegisterEventHotKey

    Hello,

    Its a cocoa application. But i didn't find anything useful in the link

    http://unsanity.org/archives/000045.php

    How can this help me.3 Please guide me a little.

    Thanks,
    Ruhi.
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    Well I was thinking that sendEvent: would work, but this doesn't get called for keys when your app isn't the frontmost, so I don't think there is a good way to do this outside of Carbon events. You could try this for a better explanation of how to do hotkeys with Carbon in Cocoa.
     

Share This Page