Global Event is Blocking

Discussion in 'Mac Programming' started by Sergio10, Jul 2, 2010.

  1. Sergio10 macrumors regular

    Joined:
    Oct 3, 2007
    #1
    Hi,

    I've developed application which works with clipboard data(text, image etc.)
    On pressing "Mac" + "C" handle event in my function. After my logic event should returns to system keyboard chain of events. But it blocks (((

    Please help with this issue. Here is a code:
    PHP:
    OSStatus MyHotKeyHandler(EventHandlerCallRef nextHandler,EventRef theEventvoid *userData)
    {
        
    NSLog(@"it works...\n");
        
    UnregisterEventHotKey(gMyHotKeyRef);
        
    SendEventToEventTarget(theEventeventTargetRef);
        return 
    noErr;
    }
    - (
    void)applicationDidFinishLaunching:(NSNotification *)aNotification 
    {
        
    //Register the Hotkey
        
    EventHotKeyID gMyHotKeyID;
        
    EventTypeSpec eventType;
        
    eventType.eventClass kEventClassKeyboard;
        
    eventType.eventKind kEventHotKeyPressed;

        
    InstallApplicationEventHandler(&MyHotKeyHandler,1,&eventType,NULL,NULL);
        
    gMyHotKeyID.signature 'htk1';
        
    gMyHotKeyID.id 1;
        
        
    eventTargetRef GetApplicationEventTarget();
        
    RegisterEventHotKey(8cmdKeygMyHotKeyIDeventTargetRef0, &gMyHotKeyRef);    
    }
    Thank you in advance.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Your SendEventToEventTarget() call is just sending the event back to the app again in an endless loop... remove it.
     
  3. Sergio10 thread starter macrumors regular

    Joined:
    Oct 3, 2007
    #3
    I remove it. Now it is not sending event to my app. But it still NOT send system "Mac" + "C" event.
     

Share This Page