Questions tagged [nsmenu]

OS X API : A class that defines an object that manages an application’s menus

365 questions
4
votes
1 answer

How to keep focus on NSStatusItem until toggling it again

I'm building an app the uses a NSStatusItem. I'm wanting my NSStatusItem to open when clicked and stay open until the user clicks the NSStatusItem again. As of right now, it opens the menu but the NSStatusItem loses focus when I click away from it…
0SX
  • 1,252
  • 6
  • 24
  • 47
4
votes
1 answer

How to enable auto generation of Window MenuItems (e.g. Tile Window to Left/Right of Screen and Open file with checkmark) in macOS menubar

I am currently creating a macOS menubar for an app without using any interface builder (no XIB/NIB files), just pure code. However I was expecting some items to be auto-generated during the start-up of the app. Items like "Start Dictation", "Emoji &…
ujin
  • 41
  • 1
4
votes
1 answer

Remove the "Open Recent" menu item in Cocoa apps

I found a bunch of people asking this (remove or disable the recent-items submenu) and no answers. After a bit of investigation ... the problem is that Apple has secretly hard-coded that particular menu to always appear - even if you delete it,…
Adam
  • 32,900
  • 16
  • 126
  • 153
4
votes
1 answer

Cocoa application menu - how to recreate?

Inside the MainMenu.xib I deleted the default Main Menu that automatically gives you the application menu (along with the File/Edit/Format/View/Window/Help menus). What are the steps I need to take to add this back into my application?
zadam
  • 2,416
  • 2
  • 23
  • 32
4
votes
4 answers

Remove highlight from NSMenuItem after click?

I have added a custom view to my subclass of NSMenuItem (which sits in a NSStatusMenu), which means that by default it will not get "highlighted" with a blue/gray background. I implemented this by using the following code: -…
rdougan
  • 7,217
  • 2
  • 34
  • 63
4
votes
4 answers

How do you hide a Menu Item with a custom view?

I am using a very simple custom view (containing only a read-only NSTextField and an NSSegmentedControl) in an NSMenuItem (using the -setView: method). This part works as expected. Here's the problem: in the -menuNeedsUpdate: NSMenu delegate method…
Dov
  • 15,530
  • 13
  • 76
  • 177
4
votes
0 answers

NSView's context NSMenu is never shown even though all the right methods are being called

I have an NSCollectionView with a bunch of NSViews in it, stacked vertically, to make it look a bit like UIKit's UITableView. Everything works as expected, except for one thing: When right-clicking any one of the NSViews, I expect the NSMenu I set…
Douwe Maan
  • 6,888
  • 2
  • 34
  • 35
4
votes
1 answer

change NSMenuItem title with Swift

I want to change the title of the MenuItem after the login process has been completed successfully and once the user logs off. But if I log in and check the title of the menu item, it has not changed. I have even tried to hide it, with no…
JRR
  • 41
  • 2
4
votes
2 answers

How do I change the main menu in Cocoa?

I have a cocoa app with two types windows each of which requires a different main menu to be displayed. In my MainMenu.xib I have the default MainMenu. In Window1.xib I have Window1 and in Window2.xib I have Window2 and it's MainMenu. When I have…
Roland Rabien
  • 8,750
  • 7
  • 50
  • 67
4
votes
2 answers

Prevent NSMenu from creating multiple instances of same NSWindow when clicked

I have a simple Cocoa Application that launches a NSWindow when an NSMenu item is clicked. I am initiating the window via a segue. The problem is when I click the menu item multiple times it keeps creating new windows instead of bringing the…
django-d
  • 2,210
  • 3
  • 23
  • 41
4
votes
0 answers

How to display a NSMenu with a search box to limit the number of results (similar to Xcode menus)

This kind of menus are available in Xcode when searching for a function name (see attached image): Is it a standard NSMenu with a customized item? Is it a fully customized NSWindow, with customs NSViews? Is there an open-source library that can…
Antoine Rosset
  • 1,045
  • 2
  • 13
  • 22
4
votes
2 answers

Get default font name in Cocoa for NSMenuItem?

I am using NSAttributed NSString in my NSMenuItem, but it's Font is changed as compare to default font, I wants to use default font for Attributed string. Can any one explain, how to find or fetch the default Font for NSMenuItems. Right now I am…
QueueOverFlow
  • 1,336
  • 5
  • 27
  • 48
4
votes
1 answer

Best way to toggle "Show/Hide" menu item in Cocoa Desktop

My app has an 'inspector' panel defined by a .xib file and a custom window controller class: AdjustmentsWindow.xib and AdjustmentsWindowController.m. I want to have a Window -> Show Adjustments menu item in the application's main menu bar, that when…
Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
4
votes
1 answer

Can I remove the top and bottom padding of a custom NSMenu?

I want to make a custom pop-up menu that has light text on a dark background. I am aware of the setView: method of NSMenuItem, which I could use to make each item draw with light text on a dark background. However, NSMenu draws 4 pixel high strips…
JWWalker
  • 22,385
  • 6
  • 55
  • 76
4
votes
1 answer

Cocoa - Assign onClick event to NSMenu

I want my status menu to call a function when it is clicked. What's the method that would let me assign that action? Something like this below but for the menu itself. NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:@"Title"…
janeh
  • 3,734
  • 7
  • 26
  • 43