Re: Generating a "left-arrow key" event
Re: Generating a "left-arrow key" event
- Subject: Re: Generating a "left-arrow key" event
- From: Dave MacLachlan <email@hidden>
- Date: Wed, 19 Apr 2006 13:28:53 -0700
On Apr 19, 2006, at 9:00 AM, Dave MacLachlan wrote:
Hey all...
I'm looking to generate a "left-arrow key" event. I tried using
NSWindow *window = [self window];
NSEvent *keyEvent = [NSEvent keyEventWithType:NSKeyDown
location:NSZeroPoint
modifierFlags:NSFunctionKeyMask
timestamp:[event time]
windowNumber:[window
windowNumber]
context:
[NSGraphicsContext graphicsContextWithWindow:window]
characters:[NSString
stringWithCharacters:&nsFuncKey length:1]
charactersIgnoringModifiers:@""
isARepeat:NO
keyCode:keyCode];
[NSApp sendEvent:keyEvent];
Where keyCode was a Mac virtual keyCode, and nsFuncKey was
NSLeftArrowFunctionKey, but when I sent that, my edit text box got
a very funky glyph. I don't want to call [NSResponder moveLeft:]
directly for a variety of complex reasons. Any ideas?
Hey folks...
All I actually needed here was:
NSString *characters = [NSString stringWithCharacters:&nsFuncKey
length:1];
NSWindow *window = [self window];
NSEvent *keyEvent = [NSEvent keyEventWithType:NSKeyDown
location:NSZeroPoint
modifierFlags:NSFunctionKeyMask
timestamp:[event time]
windowNumber:[window
windowNumber]
context:[NSGraphicsContext
graphicsContextWithWindow:window]
characters:characters
charactersIgnoringModifiers:characters
isARepeat:NO
keyCode:keyCode];
[NSApp sendEvent:keyEvent];
i.e. characters and charactersIgnoringModifiers had to match.
Cheers,
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden