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
3
votes
2 answers

Cocoa Key Equivalent in Menu is not working

I have created a NSStatusItem and I have assigned two key equivalents within interface builder (Xcode 4.0). These are for the preference menu cmd-, and the quit option cmd-q. Both of these will work when the Menu is highlighted/open but will not…
k.c
  • 35
  • 3
3
votes
0 answers

Swift - detect is NSStatusItem hidden

I'm working on MacOS menu bar app which can have variable length: @IBOutlet weak var statusMenu: NSMenu! let statusItem: NSStatusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) statusItem.title = "Long…
Tom
  • 369
  • 2
  • 14
3
votes
1 answer

How To Detect Which NSMenuItem Was Selected

Given that I have a menuBar app with 3 items on a subMenu: let delaySubMenu = NSMenu() delaySubMenu.addItem(NSMenuItem(title: "5", action: #selector( setReminder(_:)), keyEquivalent: "")) delaySubMenu.addItem(NSMenuItem(title: "10", action:…
ian
  • 11,605
  • 25
  • 69
  • 96
3
votes
1 answer

Cocoa - Custom NSView in NSMenuItem will not draw

I have a custom NSView which used to get created in a NIB and assigned as the view for an NSMenuItem, which works great, but now I want to create the view in code (for good reason I can assure you) which did not look hard but but the view is not…
Nippysaurus
  • 20,110
  • 21
  • 77
  • 129
3
votes
2 answers

Editable NSTextField in custom view of NSMenuItem

I have a subclassed NSView that I would like to contain an editable NSTextField, similar to Spotlight. I am having significant difficult getting the text field to select and highlight. If I click quickly and rapidly over the editing area of the…
Andrew J. Freyer
  • 591
  • 2
  • 12
  • 38
3
votes
1 answer

Voice over do not work in NSMenu in status bar with custom view for NSMenuItem

I have added NSMenu in NSStatusBar. I have used custom views for first NSMenuItem with the setView: method to include progressIndicator. All other items are default. Issue here is with VO (voice over for disabled people). When I enable VO from…
Durgaprasad
  • 1,910
  • 2
  • 25
  • 44
3
votes
0 answers

NSMenuItem key equivalent isn't setting

I have set menu item key equivalent to cmd- . But when I am running the application its not there.
Taras Shchybovyk
  • 416
  • 4
  • 17
3
votes
3 answers

How to flash a custom NSMenuItem view after selection?

I need to assign a view to an NSMenuItem and do some custom drawing. Basically, I'm adding a little delete button next to the currently selected menu item, among other things. But I want my custom menu item to look and behave like a regular menu…
danjonweb
  • 456
  • 3
  • 14
3
votes
2 answers

Set state of NSMenuItem to On

I have created a menu bar app and I would like when you click on one of the menu bar items it toggles between the off state and the on state (ticked and unticked) but I am struggling to do this in code. Does anyone have any ideas about how this can…
Miles.Kelly
  • 101
  • 9
3
votes
1 answer

Weird behavior of Finder Sync Extension's tool bar item menu

I am building a macOS app with Finder Sync Extension, which adds a tool bar item to the Finder. I created the tool bar item menu like this: - (NSMenu *)menuForMenuKind:(FIMenuKind)whichMenu { NSMenu *menu = [NSMenu new]; NSURL *URL = ...//…
hklel
  • 1,624
  • 23
  • 45
3
votes
2 answers

NSMenuItem Title which changes over time.

I would like to implement an NSStatusItem where the title changes over time. My ultimate goal is to display a countdown timer in the menu bar beside the image which I have set. Maybe I am going about this the wrong way. But I already have a…
dave
  • 51
  • 5
3
votes
2 answers

NSMenuItem -setTarget: Does it retain the target?

NSMenuItem -setTarget: Does it retain the target, or should one explicitly retain it? I've seen conflicting docs on this. I know of retainArguments in NSInvocation, but I'm not sure this applies to NSMenuItem as it doesn't inherit from NSInvocation.
the979kid
  • 635
  • 5
  • 15
3
votes
0 answers

NSMenuItem Hidden binding issue

I have an NSMenuItem which I have bound to an NSUserDefaults boolean value in IB. When the variable bMenuHidden is true, I would like my NSMenuItem to be hidden, and vice versa. This works as expected under Snow Leopard. However, Leopard struggles…
ndg
  • 2,585
  • 2
  • 33
  • 58
3
votes
1 answer

Programmatically adding glyphs (delete key, backspace, space, etc) to menu item

It used to be that in Carbon you could use SetMenuItemKeyGlyph. What's the alternative under 10.6? Will I need to use undocumented goodness or...? Thanks
the979kid
  • 635
  • 5
  • 15
3
votes
2 answers

Selecting the first item in a popUpContextMenu

I work on a very keyboard intensive application. Both hands on the keyboard. No hands on the mouse. A user can, via the keyboard, popup a context menu, select an item and finally hit enter. [NSMenu popUpContextMenu] displays the menu without…
neoneye
  • 50,398
  • 25
  • 166
  • 151