Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
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 theEvent, void *userData)
{
	NSLog(@"it works...\n");
	UnregisterEventHotKey(gMyHotKeyRef);
	SendEventToEventTarget(theEvent, eventTargetRef);
	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(8, cmdKey, gMyHotKeyID, eventTargetRef, 0, &gMyHotKeyRef);	
}

Thank you in advance.
 
Your SendEventToEventTarget() call is just sending the event back to the app again in an endless loop... remove it.
 
Your SendEventToEventTarget() call is just sending the event back to the app again in an endless loop... remove it.

I remove it. Now it is not sending event to my app. But it still NOT send system "Mac" + "C" event.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.