| OS X - Development and Darwin Discussion and questions about development for Mac OS X. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Nov 26, 2006
Posts: 18
![]() |
I am stuck right now on how to capture the arrow keys.I could just use the key codes but the documentation says they are hardware specific.
According to the docs. Quote:
if ([anEvent modifierFlags] & NSFunctionKeyMask ) { } will ring TRUE when the arrow keys create an event. I could use a clue as to how I can then test for the constants "NSUpArrowFunctionKey" and his partners? Every test I have tried so far ring TRUE. |
|
| QUOTE Thanks | ||
![]() Member Since: Nov 26, 2006
Posts: 18
![]() |
Not to bump the post but:
Just in case anyone is interested. I have found one way. You can load the StandardKeyBinding.dict dictionary file and check the key-value using the return from [anEvent characters] as the key. Code:
- (void)keyDown:(NSEvent *)anEvent
{
if ([anEvent modifierFlags] & NSFunctionKeyMask) {
if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveLeft:"]) {
NSLog(@"leftArrow");
}
if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveRight:"]) {
NSLog(@"rightArrow");
}
if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveDown:"]) {
NSLog(@"downArrow");
}
if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveUp:"]) {
NSLog(@"upArrow");
}
}
}
|
| QUOTE Thanks | |
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
All times are GMT -4. The time now is 04:58 PM.
Powered by vBulletin