Re: performKeyEquivalent and arrow keys
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