Re: Handling arrow key events
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.