• 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: Handling arrow key events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handling arrow key events


  • Subject: Re: Handling arrow key events
  • From: "Timothy J. Wood" <email@hidden>
  • Date: Sun, 10 Mar 2002 13:30:39 -0800

NSString *characters;
unsigned int characterIndex, characterCount;

characters = [event characters];
characterCount = [characters count];
for (characterIndex = 0; characterIndex < characterCount; characterIndex++) {
UniChar c;

c = [characters characterAtIndex: characterIndex];
switch (c) {
case NSLeftArrowFunctionKey:
....
break;
... other cases ...
}
}

There is no guarantee that the event will have only one character, so you should probably make sure that you handle all of them. Obviously this could be simplified if you want to assume that there is only one character.

-tim


On Sunday, March 10, 2002, at 12:43 PM, Jonathan Jackel wrote:

How do I handle arrow keys in a keydown: handler? Handling the delete key
is easy. I do:

if ([[event characters] isEqualToString:@"\177"])

Works great. Arrow keys return what appears to be a similar control
character, e.g., "\uf702" for left arrow, but when I put that in the if
statement I get a warning "unknown escape sequence '\u'" and it never comes
up true. I see a reference to NSLeftArrowFunctionKey in the
NSEventConstants, but I am not grasping how to make it work.

Jonathan Jackel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Handling arrow key events
      • From: Jonathan Jackel <email@hidden>
References: 
 >Handling arrow key events (From: Jonathan Jackel <email@hidden>)

  • Prev by Date: Handling arrow key events
  • Next by Date: Re: RTF Problems
  • Previous by thread: Handling arrow key events
  • Next by thread: Re: Handling arrow key events
  • Index(es):
    • Date
    • Thread