OS X API : A class that defines an object that manages an application’s menus
Questions tagged [nsmenu]
365 questions
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
1 answer
Display contextual NSMenu without blocking main thread
I had some unexpected results when displaying a contextual NSMenu. I'm presenting the menu myself, not using the menu property of an NSResponder. It turned out, presenting an NSMenu is a blocking operation.
In a new template project I only added the…

DrummerB
- 39,814
- 12
- 105
- 142
6
votes
5 answers
How to add a pop-up menu to a NSToolbarItem?
I'm trying to open a pop-up menu from a NSToolbarItem. I tried following this example but I can't use that class method because NSToolbar and NSToolbarItem inherit from NSObject and not from NSView.
Apart from creating a custom view, what is the…

ruipacheco
- 15,025
- 19
- 82
- 138
6
votes
4 answers
Contextual menu on only certain items in a "Source List"
I have a window with a Source List (NSOutlineView). My source list has just two levels. Level one is header and level two is data. I want to have a contextual menu on some of the data cells. Not all.
First, I try to attach a menu on the table cell…

Olof
- 524
- 5
- 20
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
2 answers
How Can I Show NSMenu at Mouse Cursor?
I am working on an app where I want to show an NSMenu "context menu" next to the current mouse location. At this point, I know how to trigger the command from the WebView to show the context menu, I just can't seem to get the menu to show up at the…

David
- 1,674
- 1
- 21
- 35
5
votes
3 answers
SwiftUI: Change “About View” in macOS app
I am building a macOS-app using SwiftUI and the new App lifecycle.
I would love to change the contents of the “About Window” (that appears when you tap “About DemoApp” in the apps’ menu) but have no idea how:
How can I replace the About view with a…

ixany
- 5,433
- 9
- 41
- 65
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
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
2 answers
How to have an NSMenu with dynamic actions
I want to create an NSMenu with an option similar to the Send To option you'd find in Windows Explorer where it will list the devices attached that you can send the file to.
From my research it seems that it's not possible to define a selector that…

Septih
- 1,436
- 17
- 40
5
votes
1 answer
Adding static items to "Windows" menu in Cocoa application
I have a application with 2 windows (think like Twitter Timeline and mentions). For now I have been having the menus "Timeline ⌘1" and "Mentions ⌘2" in the "File" menu but this is kind of wrong. So I moved them to the "Windows" menu just by drag and…

Jeena
- 2,172
- 3
- 27
- 46
5
votes
1 answer
cocoa NSMenu add NSMenuItem in position
I'm trying to create an NSMenu in my application. I succesfully create the menu, with some fixed items, and now I have to add some items programmatically. I succeed also in that, but it adds the item at the bottom of the others. There's a way to put…

phcaze
- 1,707
- 5
- 27
- 58
4
votes
1 answer
Custom NSMenu like view not displaying selectedMenuItemColor correctly
I wrote my own NSMenu like class to show dynamic search results below a NSSearchField in a borderless NSWindow. It's working well but doesn't draw the magic selectedMenuItemColor correctly if I add some padding to the top of the subview. I put a 5…

John Wright
- 2,418
- 4
- 29
- 34
4
votes
1 answer
Creating dynamic count of NSMenuItems
I'm currently struggling with dynamic UI in Mac OS X.
I created a Menu Bar item and want to add a dynamic count of MenuItems within it.
The count of the elements depends on Network interfaces on the computer.
My Mac got two Interfaces, another got…

Julian F. Weinert
- 7,474
- 7
- 59
- 107