• 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: detect command key status
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: detect command key status
      • From: j o a r <email@hidden>
    • Re: detect command key status
      • From: glenn andreas <email@hidden>
References: 
 >detect command key status (From: Richard Salvatierra <email@hidden>)

  • Prev by Date: detect command key status
  • Next by Date: unmount device stop application
  • Previous by thread: detect command key status
  • Next by thread: Re: detect command key status
  • Index(es):
    • Date
    • Thread