• 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: performKeyEquivalent and arrow keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: performKeyEquivalent and arrow keys


  • Subject: Re: performKeyEquivalent and arrow keys
  • From: Charilaos Skiadas <email@hidden>
  • Date: Wed, 23 Mar 2005 10:35:00 -0600

I don't know if this applies to your setting, but I wanted to catch arrow keys in an NSTextField, and I did it by implementing the delegate method:

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
{
NSLog(@"Handling event");
if ((command == @selector(moveDown:))) {
[self moveInHistoryDown:control];
return YES;
}
if ((command == @selector(moveUp:))) {
[self moveInHistoryUp:control];
return YES;
}
return NO;
}


Come to think of it, wasn't this discussed in the list recently? Check the archives.
Haris
On Mar 23, 2005, at 8:30 AM, Luc Vandal wrote:


Hi,

I'm using performKeyEquivalent to track some keyboard events. I have some problems with the arrow keys. I'm using the modifier key to see which arrow key has been pressed. Here's some code:

-(BOOL)performKeyEquivalent:(NSEvent*)event
{
	BOOL bHandled = YES;

	m_nModifierKey	= [event modifierFlags];
	m_strKey				= [event charactersIgnoringModifiers];
	m_bRepeat				= [event isARepeat];

	NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
	[center postNotificationName:NSKeyDownNotification object:nil];

	return bHandled;
}

- (void)KeyDown:(NSNotification*)notification
{
	int nModifier = [m_pWnd GetModifier];
	int i=0;
	NSString* strKey = [m_pWnd GetKey];
	BOOL bRepeat = [m_pWnd GetIsARepeat];
	...
	...
	else if( nModifier & NSRightArrowFunctionKey )
		{
			//todo
		}

Now that I think about it, it probably doesn't make sense to use the modifier value? What is the proper way to handle arrow keys?

Thanks!

Luc  _______________________________________________


_______________________________________________ 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
  • Follow-Ups:
    • Re: performKeyEquivalent and arrow keys
      • From: Luc Vandal <email@hidden>
References: 
 >performKeyEquivalent and arrow keys (From: Luc Vandal <email@hidden>)

  • Prev by Date: Re: Newbie: Binding and NSPopUpButton question. Answered my self.
  • Next by Date: Re: Case insensitive autocomplete
  • Previous by thread: performKeyEquivalent and arrow keys
  • Next by thread: Re: performKeyEquivalent and arrow keys
  • Index(es):
    • Date
    • Thread