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

Solved: performKeyEquivalent and arrow keys


  • Subject: Solved: performKeyEquivalent and arrow keys
  • From: Luc Vandal <email@hidden>
  • Date: Wed, 23 Mar 2005 13:13:38 -0500

Added if( [event type] == NSKeyDown )


On 23-Mar-05, at 12:33 PM, Luc Vandal wrote:

Also, when I hit for example the right arrow, performKeyEquivalent is being called twice. Is it called for the key down and then for the key up? Is there a way to know if the key is down or up?



On 23-Mar-05, at 11:35 AM, Charilaos Skiadas wrote:

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
 _______________________________________________
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

References: 
 >performKeyEquivalent and arrow keys (From: Luc Vandal <email@hidden>)
 >Re: performKeyEquivalent and arrow keys (From: Charilaos Skiadas <email@hidden>)
 >Re: performKeyEquivalent and arrow keys (From: Luc Vandal <email@hidden>)

  • Prev by Date: Re: loop efficiency & messages
  • Next by Date: Re: Case insensitive autocomplete
  • Previous by thread: Re: performKeyEquivalent and arrow keys
  • Next by thread: Case insensitive autocomplete
  • Index(es):
    • Date
    • Thread