Send Key Event to Focused Window
Send Key Event to Focused Window
- Subject: Send Key Event to Focused Window
- From: Daniel <email@hidden>
- Date: Wed, 18 Jun 2008 09:31:17 +0200
Hi to all,
I'm developing a tool for assistive input and my question is how can I
send a key event (like a keyboard press event) to the current window
(whatever this one could be), for data input.
I've tried the following, but only a beep is produced by my machine.
<snippet>
id keyTarget = [[NSApp keyWindow] firstResponder];
NSEvent *aKeyDownEvent = [NSEvent keyEventWithType:NSKeyDown
location:NSMakePoint(0,0)
modifierFlags:0
timestamp:[NSDate timeIntervalSinceReferenceDate]
windowNumber:[[NSApp keyWindow] windowNumber]
context:[[NSApp keyWindow] graphicsContext]
characters:@"Q"
charactersIgnoringModifiers:@"Q"
isARepeat:NO keyCode:0];
[keyTarget keyDown:aKeyDownEvent];
</snippet>
Thank you in advance,
Daniel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden