• 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: set keyEquivalent for an NSMenuItem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set keyEquivalent for an NSMenuItem


  • Subject: Re: set keyEquivalent for an NSMenuItem
  • From: Andy Lee <email@hidden>
  • Date: Thu, 19 May 2011 09:00:22 -0400

On May 19, 2011, at 8:42 AM, Martin Batholdy wrote:

> Hi,
>
> I use the ShortcutRecorder framework in order to let the user define a shortcut for a given action.
>
> The ShortcutRecorder framework saves the shortcut into the preference plist in the following form:
>
> keyCode: 18
> modifiers: 256
> (for CMD +1)
>
>
> Now I would like to use this information from the plist to display the shortcut in a NSMenuItem.
>
> - (id)initWithTitle:(NSString *)itemName action:(SEL)anAction keyEquivalent:(NSString *)charCode

Haven't tried this, but looking at the functions in SRCommon I'd try something like:

NSString *keyString = SRStringForKeyCode(18);
NSUInteger modifierMask = 256;
NSMenuItem *myMenuItem = [[[NSMenuItem alloc] initWithTitle:@"My Menu Item"
                                                     action:@selector(myAction:)
                                              keyEquivalent:keyString]
                          autorelease];
[myMenuItem setKeyEquivalentModifierMask:modifierMask];

--Andy

>
>
> Now how can I transform the information I have to the NSString the NSMenuItem accepts and displays?
>
>
> thanks!_______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: set keyEquivalent for an NSMenuItem
      • From: Martin Batholdy <email@hidden>
References: 
 >set keyEquivalent for an NSMenuItem (From: Martin Batholdy <email@hidden>)

  • Prev by Date: set keyEquivalent for an NSMenuItem
  • Next by Date: Installing application on a network onto several computers
  • Previous by thread: set keyEquivalent for an NSMenuItem
  • Next by thread: Re: set keyEquivalent for an NSMenuItem
  • Index(es):
    • Date
    • Thread