Questions tagged [nsmenuitem]

The NSMenuItem class from AppKit.framework in Mac OS, defines objects that are used as command items in menus.

The NSMenuItem class defines objects that are used as command items in menus. Additionally, the NSMenuItem class also includes some private functionality needed to maintain binary compatibility with other components of Cocoa. Because of this fact, you cannot replace the NSMenuItem class with a different class. You may, however, subclass NSMenuItem if necessary.

Prior to Mac OS X v10.5, NSMenuItem conformed to the following protocols: NSCopying, NSCoding), and NSValidatedUserInterfaceItem.

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenuItem_Class/Reference/Reference.html

331 questions
4
votes
1 answer

change NSMenuItem title with Swift

I want to change the title of the MenuItem after the login process has been completed successfully and once the user logs off. But if I log in and check the title of the menu item, it has not changed. I have even tried to hide it, with no…
JRR
  • 41
  • 2
4
votes
2 answers

How to add a selector to a menu item when using storyboard

I know how to do it programatically, creating a menu and adding menu items and then assigning selector to it and eventually calling a function. But what i am not able to figure out is how do i execute a function when an NSMenuItem was added using…
KD.
  • 2,015
  • 3
  • 28
  • 59
4
votes
3 answers

Swift 2.2 selector in NSMenuItem

I have a simple one file menu bar app in swift: import Cocoa class StatusBarApp : NSObject { func buildMenu() { let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength) statusItem.title =…
lutrekubej
  • 63
  • 1
  • 3
4
votes
0 answers

When is the enclosingMenuItem of an NSView set?

In writing a custom NSMenuItem view, I am accessing the associated NSMenuItem via the NSView enclosingMenuItem message. I would like to be able to update some subviews of my custom NSMenuItem view just as soon as I know that the enclosing menu item…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
4
votes
1 answer

How to create the NSMenuItem view for a menu item with an embedded NSProgressIndicator?

I would like to create a menu item with an embedded NSProgressIndicator, similar to the "Wi-Fi: Looking for Networks…" menu item of the Wi-Fi status menu: I think that I will need to use the setView: method as discussed at: Views in Menu Items. …
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
4
votes
2 answers

How can I remove the white square around my NSProgressIndicator?

I'm adding an NSProgressIndicator to my NSMenuItem (with a custom view). It works fine, but it has a weird square around it: Here is my code: // In my @interface declaration: NSProgressIndicator *_spinner; ... // In initWithFrame: _spinner =…
David Murray
  • 541
  • 5
  • 19
4
votes
2 answers

Get default font name in Cocoa for NSMenuItem?

I am using NSAttributed NSString in my NSMenuItem, but it's Font is changed as compare to default font, I wants to use default font for Attributed string. Can any one explain, how to find or fetch the default Font for NSMenuItems. Right now I am…
QueueOverFlow
  • 1,336
  • 5
  • 27
  • 48
3
votes
2 answers

Weird behavior using keyEquivalent on NSMenuItem

I wanted to be able to set the keyEquivalent of an NSMenuItem based on an NSString, e.g. : CMD+R, ALT+SHIFT+D, etc For this, I created a method in an NSString category as following (debugging NSLogs included) : - (NSDictionary*)toKeyEquivalent { …
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
3
votes
1 answer

Custom view in NSMenuItem disables the NSPopUpButton selection

I want to customize an an NSPopUpButton so I have implemented an CustomMenuItemView which right now only has the following code (for testing purposes): - (void)drawRect:(NSRect)dirtyRect { [[NSColor redColor] set]; …
pajevic
  • 4,607
  • 4
  • 39
  • 73
3
votes
4 answers

How to connect a menu item to a custom action defined in the NSApplication delegate across nib files?

In my Cocoa app I have two NIB/XIB files that I need to connect: MainMenu.xib: contains a custom object for the NSApplication delegate object and connects it to the proper outlet in the NSApplication placeholder. ContextMenu.xib: sets up an NSMenu;…
Mark
  • 6,647
  • 1
  • 45
  • 88
3
votes
3 answers

Certain key equivalents cannot be used for NSMenuItem

I have an NSMenuItem for which I would like to use the key equivalent Command-Option-C. However, when I set the key equivalent in IB, it does not get associated with the menu item when the app is actually run. The entry has no visible key…
Jordan Kay
  • 368
  • 3
  • 14
3
votes
1 answer

When to remove dynamic NSMenuItem's from an NSMenu

I have an NSMenu which contains a number of dynamic items. These items are created in NSMenuDelegate's menuNeedsUpdate method and are each assigned a representedObject. I'm looking to trim the object graph and hopefully regain a bit of memory when…
ndg
  • 2,585
  • 2
  • 33
  • 58
3
votes
2 answers

How to create an NSMenu containing an NSMenuItem which only appears while holding a keyboard modifier key?

I'd like to create an NSMenu containing an NSMenuItem which is hidden by default, and only appears while the user is holding a keyboard modifier key. Basically, I'm looking for the same behaviour as the 'Library' option in the Finder's 'Go'…
Noah Nuebling
  • 219
  • 2
  • 11
3
votes
2 answers

How do I adjust the size of an NSMenu to its content dynamically?

I have a standard NSMenu like this This menu was created with this code: NSMenu *menu = [[NSMenu alloc] init]; NSMenuItem *addMenuItem = [[NSMenuItem alloc] init]; [addMenuItem setTitle:[NSString stringWithFormat:@"Upload"]]; [addMenuItem…
Bruno Berisso
  • 1,091
  • 11
  • 33
3
votes
1 answer

NSMenuItem with attributedTitle containing an NSFont object draws the title with baseline shift

I'm tying to create an NSPopUpButton with the list of fonts available in the system. Seemed pretty obvious task but I've failed. I guess, I'm missing something so obvious that I've completely forgot about it. The code is pretty straight: let button…
Vitalii Vashchenko
  • 1,777
  • 1
  • 13
  • 23