Re: detect command key status
Re: detect command key status
- Subject: Re: detect command key status
- From: Richard Salvatierra <email@hidden>
- Date: Mon, 27 Jun 2005 11:07:58 -0400
Thanks for your suggestions. Not sure why the NSCommandKeyMask does
not cover my command keys though.
I have to check for other modifierflags.
- (void) flagsChanged:(NSEvent *)theEvent {
int modifierflag = [theEvent modifierflag];
if( modifierflag == NSCommandKeyMask || modifierflag == 1048840
|| modifierflag == 1048584 || modifierflag == 1048848) {
commandKeyDown = YES;
}else if(modifierflag == 256){
commandKeyDown = NO;
}
}
What is the best way to detect the command key down / up?
There must be something more elegant then:
- (void) flagsChanged:(NSEvent *)theEvent
{
if([theEvent modifierFlags] == 1048840 | [theEvent
modifierFlags] == 1048584 | [theEvent modifierFlags] == 1048848){
commandKeyDown = YES;
}
if([theEvent modifierFlags] == 256){
commandKeyDown = NO;
}
}
Some random suggestions:
- save the [theEvent modifierFlags] result in a variable to avoid
calling it 4 times.
- use || instead of |.
- add a else between the 2 if
- use constants.
- don't mix 2 {} styles.
My $0.02
_______________________________________________
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