Questions tagged [nsmenu]

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

365 questions
4
votes
1 answer

Respond to Open Recent clicks in NSMenu

I am trying to respond to a user clicking an item in the Open Recent menu in my non-document based Cocoa app. I can handle File->Open by attaching it to an IBAction in IB. However, I cannot figure out how to handle when a user clicks something from…
user1032657
  • 2,451
  • 6
  • 28
  • 38
4
votes
1 answer

Updating an NSmenu from an asynchronous NSURLConnection

I am writing a little systray application that fetches data from an API and updates its menu accordingly, and am having trouble with updating the menu while it's open. I don't even know where to start, so let's start with the beginning. I have a…
Geoffrey Bachelet
  • 4,047
  • 2
  • 21
  • 17
4
votes
1 answer

Main Thread Runloop gets blocked on opening nsmenu

I have an application for which the UI element includes an NSStatusItem and a menu. Inside my application , I am using NSTask asynchronously to perform some operation and I am using the output obtained using the …
3
votes
1 answer

NSView custom context menu and keys

i have an NSCollectionView in my application's main window that manages a collection of custom NSView items. Each custom view has a context menu assigned to it. I want to add shortcut keys to some of the items, for example to associate a "delete"…
Inso Reiges
  • 1,889
  • 3
  • 17
  • 30
3
votes
1 answer

When to remove dynamic NSMenuItem's from an NSMenu

I have an NSMenu which contains a number of dynamic items. These items are created in NSMenuDelegate's menuNeedsUpdate method and are each assigned a representedObject. I'm looking to trim the object graph and hopefully regain a bit of memory when…
ndg
  • 2,585
  • 2
  • 33
  • 58
3
votes
2 answers

How to create an NSMenu containing an NSMenuItem which only appears while holding a keyboard modifier key?

I'd like to create an NSMenu containing an NSMenuItem which is hidden by default, and only appears while the user is holding a keyboard modifier key. Basically, I'm looking for the same behaviour as the 'Library' option in the Finder's 'Go'…
Noah Nuebling
  • 219
  • 2
  • 11
3
votes
2 answers

How do I adjust the size of an NSMenu to its content dynamically?

I have a standard NSMenu like this This menu was created with this code: NSMenu *menu = [[NSMenu alloc] init]; NSMenuItem *addMenuItem = [[NSMenuItem alloc] init]; [addMenuItem setTitle:[NSString stringWithFormat:@"Upload"]]; [addMenuItem…
Bruno Berisso
  • 1,091
  • 11
  • 33
3
votes
2 answers

Toggle NSStatusItem's Menu Open/Closed Using Hot Key - Code Execution Queued/Blocked

I'm editing this question because I think I may have oversimplified the way in which my status item's menu opens. It's ridiculously complicated for such a simple function! My status item supports both left and right click actions. The user can…
3
votes
0 answers

Swift - detect is NSStatusItem hidden

I'm working on MacOS menu bar app which can have variable length: @IBOutlet weak var statusMenu: NSMenu! let statusItem: NSStatusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) statusItem.title = "Long…
Tom
  • 369
  • 2
  • 14
3
votes
3 answers

How to get rid of Enter Full Screen menu item?

In my Mac OS X app I deleted all default menu items, added my own. But in View menu at the bottom I can still see Enter Full Screen menu item, whilst in storyboard there is no such menu item. I've tried to delete the entire View menu, but now it…
Pablo
  • 28,133
  • 34
  • 125
  • 215
3
votes
1 answer

How To Detect Which NSMenuItem Was Selected

Given that I have a menuBar app with 3 items on a subMenu: let delaySubMenu = NSMenu() delaySubMenu.addItem(NSMenuItem(title: "5", action: #selector( setReminder(_:)), keyEquivalent: "")) delaySubMenu.addItem(NSMenuItem(title: "10", action:…
ian
  • 11,605
  • 25
  • 69
  • 96
3
votes
1 answer

How can you specify which NSMenu is the main menu in a XIB file?

Long time iOS developer who's dipping his toes in the macOS world. Just trying to better understand how Mac apps work. For non-storyboard applications based on a XIB, the template creates a default xib and inside is the application's main…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
3
votes
0 answers

NSMenuItem key equivalent isn't setting

I have set menu item key equivalent to cmd- . But when I am running the application its not there.
Taras Shchybovyk
  • 416
  • 4
  • 17
3
votes
1 answer

How to display search bar in NSMenuItem

I'm building a MenuBar Swift Cocoa application that displays a list of user's github repositories. After clicking on one, it opens a new browser window with the repository on github.com. I am successfully loading the list of repos and rendering them…
Jerguš Lejko
  • 610
  • 4
  • 25
3
votes
1 answer

Weird behavior of Finder Sync Extension's tool bar item menu

I am building a macOS app with Finder Sync Extension, which adds a tool bar item to the Finder. I created the tool bar item menu like this: - (NSMenu *)menuForMenuKind:(FIMenuKind)whichMenu { NSMenu *menu = [NSMenu new]; NSURL *URL = ...//…
hklel
  • 1,624
  • 23
  • 45