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
6
votes
1 answer

Cocoa custom view for NSMenuItem

I am developing a small app that display the active mounts in a menu in the NSStatusBar. So far it looks like this: I want to add an eject button to the right of each menu item (like the left bar in the Finder). I know that I have to create a…
user212926
6
votes
0 answers

Custom View in NSMenuItem does not highlight correctly

I try to use a custom view for a NSMenuitem, which works. Unfortunately, I have some difficulties with the highlighting (mouseover). I already followed the instructions in other threads to implement drawRect: in my NSView subclass to do the blue…
Fabian Jäger
  • 447
  • 1
  • 5
  • 12
6
votes
4 answers

NSMenuItem height?

How can I change the height of an NSMenuItem? When I change the font of a menu, an NSMenuItem automatically resizes to just fit the title, leaving no space above or below the title. It looks very cramped. Looks like this: Want it to look like…
danjonweb
  • 456
  • 3
  • 14
6
votes
3 answers

Change background color on hover on a NSMenuItem with custom NSView

Here is the thing: I have created a custom NSMenuItem with a custom NSView in it. Everything works fine except that I can't get the NSMenuItem to get highlighted (= change the background color on mouseover). I'm trying to do it inside the drawRect…
ozmax
  • 470
  • 6
  • 17
6
votes
4 answers

How to set the font of NSMenu/NSMenuItems?

I can’t figure out how to set the font/styling of my NSMenuItems in my NSMenu. I tried the setFont method on the NSMenu but it doesn’t seem to have any effect on the menu items. NSMenuItem doesn’t seem to have a setFont method. I would like for…
JPC
  • 8,096
  • 22
  • 77
  • 110
5
votes
2 answers

Can a variable be passed into an NSMenu action?

I am dynamically building menu's based on an array and there is a sub-menu is linked to an IBAction which opens a folder in Finder. The folder it opens is based on a property of the object in my initial array. Is there a way of linked the NSMenuItem…
Coderama
  • 11,050
  • 12
  • 44
  • 58
5
votes
1 answer

Can not get rid of Shift-Key in NSMenuItem Modifier Mask

I have a NSMenuItem that has a keyboard shortcut. I set the shortcut like this: // Close let closeItem = NSMenuItem() closeItem.title = Resources.QUIT closeItem.action = #selector(quit) closeItem.keyEquivalentModifierMask =…
inexcitus
  • 2,471
  • 2
  • 26
  • 41
5
votes
1 answer

Adding a NSMenu to a NSTableCellView which pops up on right click

I want to popup a NSMenu when the user right-clicks on a NSTableCellView within a NSTableView. let cell = myTableView.make(withIdentifier: "myCustomTableCellView", owner: self) as! MyTableCellView // subclass of NSTableCellView let menu =…
ixany
  • 5,433
  • 9
  • 41
  • 65
5
votes
0 answers

NSTextField does not get focus back after losing focus

I have set an NSMenuItem's view to a custom view, which contains a textfield. When I run the program, everything works as expected. NSTextField is part of the NSStatusItem and accepts focus and I can type things in it. After closing the menu and…
felix
  • 11,304
  • 13
  • 69
  • 95
5
votes
1 answer

How can I put multiple lines of text in an NSMenuItem?

I would like to create an NSMenuItem with more than one line of text in it, and I'd also like an icon to appear next to both lines of text. I can't use a custom view, because then it wouldn't highlight correctly, and I can't just put a newline in…
tbodt
  • 16,609
  • 6
  • 58
  • 83
5
votes
1 answer

NSMenu highlight specific NSMenuItem

How to highlight a specific NSMenuItem? There is just the method highlightedItem on the NSMenu, but no setHighlightedItem
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
5
votes
1 answer

NSMenuItem is not enabled swift

I have a NSMenuItem in my project: var statusBar = NSStatusBar.systemStatusBar() var statusItem : NSStatusItem = NSStatusItem() var menuItem : NSMenuItem = NSMenuItem() var mainMenu = NSMenu() override func viewDidLoad() { …
user4226616
5
votes
1 answer

Dynamically update NSMenuItem from an NSTimer while the menu is currently open in swift?

So here's my situation, I have a little app that will keep track of how long you have been working and let you know when it's time to take a break. I have an NSTimer that fires every second and updates some numbers (the remaining time). The app…
Spencer Wood
  • 610
  • 6
  • 15
5
votes
0 answers

How to specify accessibility attribute values for the menu item when using a custom view?

I am writing a custom NSMenuItem view that I would like to make accessible. When I do not override accessibilityIsIgnored (so the NSView default of YES is returned), I see in Accessibility Inspector that there is a basic AXMenuItem object in the…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
5
votes
2 answers

NSMenuItem action is not executing

I am creating a status bar on my app and the menus show up fine, however it does not seem to access the actions that I have set up for it. I am adding the status bar through a C function: void MyFunction(CefRefPtr browser) { …