• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Generating a "left-arrow key" event
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Generating a "left-arrow key" event (From: Dave MacLachlan <email@hidden>)

  • Prev by Date: Re: object Allocation
  • Next by Date: Re: object Allocation
  • Previous by thread: Generating a "left-arrow key" event
  • Next by thread: baseline alignment of NSTextAttachment doesn't seem to always align...?
  • Index(es):
    • Date
    • Thread