OS X API : A class that defines an object that manages an application’s menus
Questions tagged [nsmenu]
365 questions
10
votes
2 answers
How to accept editing and dismiss pop-up menu containing custom view?
I want to add the ability to use a date picker when editing a particular column in my table view, and used the code snippet from here, which worked well. However NSDatePicker is not appropriate for my needs so I am using my own custom view, created…

trojanfoe
- 120,358
- 21
- 212
- 242
9
votes
1 answer
SwiftUI: How to implement Edit menu in macOS app
I am building a macOS-app using SwiftUI and the new App lifecycle.
All the default macOS menu items (like cut, copy, paste) are already there after starting a new project but they’re greyed out. How can I implement methods for these default menu…

ixany
- 5,433
- 9
- 41
- 65
9
votes
2 answers
Modify NSMenu structure on each open?
I need to be able to dynamically modify an NSMenu hierarchy each time it is shown (add/remove items etc). For example:
user starts a tracking session on a main menu and selects a submenu
detect submenu is about to open and run code to modify…

Chris
- 1,522
- 1
- 12
- 19
9
votes
3 answers
How to add NSMenu Programmatically?
I didn't use storyboard and xib, just used only code.
I would like to add "Edit" Menu Programmatically. My Questions are
1) How to show "Edit" Menu / What codes need to input at comment Question 1)?
2) There are any actions provided from swift like…

Astin
- 137
- 1
- 1
- 9
9
votes
2 answers
Swift: NSStatusItem menu behaviour in 10.10 (e.g. show only on right mouse click)
I am writing a simple status bar app in Swift, and attempting to use the new NSStatusItem API introduced in OS X 10.10.
The interface I'm aiming for is a simple left mouse click on the statusItem to toggle a core feature on and off, with a right…

Kieran
- 771
- 7
- 14
9
votes
1 answer
Weird issue with NSMenuItem, custom view and mouseUp:
I'm having a very very strange issue here with a NSMenu.
About half the NSMenuItems I use have custom views on them through the setView: method on NSMenuItem. In this custom view I've implemented mouseUp: to catch when the user clicks on the menu…

Christian A. Strømmen
- 3,181
- 2
- 25
- 46
9
votes
3 answers
NSTableView to allow user to choose which columns to display
Anyone knows how to allow users to choose which columns of an NSTableView to be displayed by right clicking and then selecting? Just like iTunes does.

David James
- 635
- 6
- 16
9
votes
5 answers
Hide/Show menu item in application's main menu by pressing Option key
I want to add a menu item into the application's main menu that will be used quite rare. I want it to be hidden by default and show it only when user hold down Option key. How do i do this?
It seems that I should handle flagsChanged:, but it is…

Vladimir Prudnikov
- 6,974
- 4
- 48
- 57
9
votes
3 answers
How to update NSMenu while it's open?
I have a NSMenu with dynamically added NSMenuItems. The NSMenu is not refreshing properly while it's kept open. I am calling NSMenu update method in NSEventTrackingRunLoopModes.
I have implemented following methods to update NSMenu.
-…

Vinpai
- 1,689
- 3
- 16
- 18
8
votes
1 answer
How to place Horizontal Slider in NSMenu (Swift 3, Xcode 8)
As of macOS Sierra the volume menu bar item provides a horizontal slider item to change the system's volume:
I'd like to adopt this concept for my own application and came up with the following class:
import Cocoa
@NSApplicationMain
class…

Zahlex
- 628
- 2
- 8
- 18
8
votes
1 answer
Disabling/enabling an application menu item
In trying to learn the very fundamentals of menu handling. My test app's menubar has 3 menus -- namely "TestApp", "File" and "Help". I find I can remove these menus entirely, simply by calling say:
NSMenu* rootMenu = [NSApp mainMenu];
[rootMenu…

Bender
- 357
- 5
- 15
8
votes
3 answers
validateMenuItem: not called
I'm facing a weird situation. I've got an NSMenu with a submenu in it. The submenu's contents are populated programmatically. In my validateMenuItem: method, I can see all items being checked (the parent's items) as well as the subitems (once I…

Dr.Kameleon
- 22,532
- 20
- 115
- 223
8
votes
1 answer
NSMenu animations block main thread
I have:
NSStatusItem with a custom view (scrolling text in a secondary thread), with the secondary thread updating the internal state and notifying the main thread with setNeedsDisplay.
On mouseDown, an NSMenu pops up.
However, if any NSMenuItem in…

tentonwire
- 81
- 1
7
votes
2 answers
How can i pop up NSMenu at mouse cursor position?
I want to react on hot key press by displaying NSMenu at mouse cursor position.
My application is UIElement and doesn't have its own window.
I know there is method of NSMenu :
-(void)popUpContextMenu:(NSMenu *)menu
…

flagman
- 502
- 4
- 18
7
votes
1 answer
NSMenuItem enable items
I have an NSMenuItem with a bunch of items in it, however... the list just doesn't get enabled.
What I mean:
This is my code:
- (void)didFetchNewList:(NSArray *)list
{
NSArray *smallList = [list subarrayWithRange:NSMakeRange(0, 10)];
…

Paul Peelen
- 10,073
- 15
- 85
- 168