OS X API : A class that defines an object that manages an application’s menus
Questions tagged [nsmenu]
365 questions
7
votes
5 answers
set titles of items in my app's main menu?
I am trying to change the titles of some of the items in my Cocoa app's main menu. I have tried setting them both within IB and also programmatically from my app's applicationDidFinishLaunchingWithOptions: method. Either way, the title property of…

William Jockusch
- 26,513
- 49
- 182
- 323
7
votes
1 answer
Programmatically creating menus with Swift 3 and Cocoa
I am trying my hand at creating a Cocoa GUI app programmatically (i.e. without a nib file) using Swift 3. I've run into trouble getting the application's menus to show.
I would expect the below code to show a File menu items on the menu bar.…

balster neb
- 127
- 1
- 10
7
votes
1 answer
Capture key press events while NSMenu is open
I'm interested in capturing key presses while a NSMenu is open. For example, if the menu is open and the user presses "e", or "1" on the keyboard, send a particular message (preferably passing an event object which contains reference to which key…

Dustin Senos
- 243
- 1
- 9
7
votes
1 answer
How to draw an inline style label (or button) inside NSMenuItem
When App Store has updates, it shows an inline style element in the menu item, like '1 new' in the screenshot below:
Another place we can see this kind of menu is 10.10 Yosemite's share menu. When you install any app that adds a new share…

James Chen
- 10,794
- 1
- 41
- 38
7
votes
1 answer
Alternative Menu Items in NSMenu
I have an NSMenu that contains NSMenuItems with custom views. I want it so that when the alt button is pressed, the menu items would change part of their look (through their view). I found setAlternative in the NSMenuItem docs, however, in…

Nick Paulson
- 111
- 1
- 5
7
votes
4 answers
How to add multiple menu items with the same title to NSPopUpButton(NSMenu)?
As docs say it's impossible to add two menu items to NSPopUpButton if they both have the same title. I was trying to add menu items to [popupButton menu], but with no luck. I was also trying to create a new menu, add items to it and then use…

William S. Pear
- 73
- 1
- 3
7
votes
7 answers
Remove (or customize) 'Search' from help menu
My app has the default 'Help' menu. I have removed the 'Help' entry and added a Support entry that links to a forum on my website.
The help menu nib looks like this:
But once I have the app up and running a new menu item has been suck in:
How can…

Kyle
- 17,317
- 32
- 140
- 246
6
votes
2 answers
Disclosure button displaying a menu
Please give me an advice how to implement this kind of disclosure button as on my screenshot - a disclosure "arrow down" button displaying a menu on click:
I've tried two approaches, using NSPopupButton and NSButton with disclosure style and manual…

iHunter
- 6,205
- 3
- 38
- 56
6
votes
0 answers
NSMenuItem with custom view in macOS 11 Big Sur
macOS 11 Big Sur in its current iteration (beta 1 through beta 6) has a bug/feature that makes it hard to have NSMenuItem with the custom view. Specifically, the custom view of an item won't get a draw(dirtyRect:) call when the menu item gets…

Vitalii Vashchenko
- 1,777
- 1
- 13
- 23
6
votes
2 answers
NSTextfield + NSMenu and first responder
I'm trying to implement my own autocomplemention system (result is pull from an sqlite database)
I've set up a NSTextField and the appropriate delegate. Each time the text in the NSTextField change, it call -…

Dimillian
- 3,616
- 4
- 33
- 53
6
votes
1 answer
Creating 1Password-like macOS menubar app
I am trying to create a macOS menubar app which will have a text field as the first item. The textfield will serve as a search bar for filtering other items which will be displayed below it.
It should look very similar to 1password:
This is what I…

Jerguš Lejko
- 610
- 4
- 25
6
votes
1 answer
Set focus on a NSTextField in an NSMenu?
I have an NSMenu in the Mac statusbar, inside it I have a load of NSMenuItems and a custom view. Inside the custom view I have an NSTextField. I want to set the focus on the NSTextField when the menu is opened as in the Spotlight menu so the user…

Alex Stuckey
- 1,250
- 1
- 14
- 28
6
votes
0 answers
swift how to delay mac menu bar appearing animation
The Problem:
on a full screen mac app, when you move the mouse pointer to the top, the mac menu bar will instantly drop down. I'd like to make an app which delays the showing of the menu bar by a couple seconds.
It should be possible since that is…

gietal
- 129
- 10
6
votes
2 answers
Intercepting NSMenu key events
I am making a search field, which opens a NSMenu similar to Finder and Mail
The only problem, which drives me crazy, is that i cannot intercept the key events, once the menu is open
I even subclassed the NSApplication sendEvent, but was surprised…

Peter Lapisu
- 19,915
- 16
- 123
- 179
6
votes
1 answer
NSMenu delegate not called to populate it
I have a controller object that owns an NSMenu and is that menu's delegate, in the interest of lazy population.
However, neither numberOfItemsInMenu: nor menuNeedsUpdate: is ever called, and so the menu remains empty.
I have confirmed that:
The…

Peter Hosey
- 95,783
- 15
- 211
- 370