New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

[cocoa keyboardInput]


Post Reply New Thread Subscribe

 
Thread Tools
Three

 
Member Since: Nov 26, 2006
Posts: 18
Three is on a distinguished road

Three is offline
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:
Note that some function keys are handled at a lower level and are never seen by your application...
The Arrow keys are considered function keys from what I gather because,

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
Three

 
Member Since: Nov 26, 2006
Posts: 18
Three is on a distinguished road

Three is offline
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");
		}
	}
}
If anyone knows a better way, for that matter any other way, please let me know.
QUOTE Thanks

Post Reply New Thread Subscribe


« Software Development on a Mac -- What do you use? | Apple script to alter screen »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

All times are GMT -4. The time now is 03:40 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?