Questions tagged [nsmenuitem]

The NSMenuItem class from AppKit.framework in Mac OS, defines objects that are used as command items in menus.

The NSMenuItem class defines objects that are used as command items in menus. Additionally, the NSMenuItem class also includes some private functionality needed to maintain binary compatibility with other components of Cocoa. Because of this fact, you cannot replace the NSMenuItem class with a different class. You may, however, subclass NSMenuItem if necessary.

Prior to Mac OS X v10.5, NSMenuItem conformed to the following protocols: NSCopying, NSCoding), and NSValidatedUserInterfaceItem.

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenuItem_Class/Reference/Reference.html

331 questions
10
votes
1 answer

How to customize NSMenu like the Apple Pro Apps?

I want to customize a NSMenu with NSMenuItems, so does it looks like the Apple Pro Apps. But how can I customize a NSMenu? There is no draw method to change the appearance. If I set a NSView to a NSMenuItem, I can set the background color, but I…
Matt
  • 448
  • 5
  • 16
10
votes
3 answers

How to set function keys as key equivalents programmatically

From NSMenuItem Class Reference If you want to specify the Backspace key as the key equivalent for a menu item, use a single character string with NSBackspaceCharacter (defined in NSText.h as 0x08) and for the Forward Delete key, use…
vcirilli
  • 321
  • 3
  • 13
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
1 answer

How to add icons to the right hand side of NSMenuItem

I'm trying to add some icons to the right hand side of a menu next to a menu item, ideally all right justified. I'm aware that NSMenuItem allows you to add menu items (for instance, see the MenuMadness example). I'm really looking for something like…
leecbaker
  • 3,611
  • 2
  • 35
  • 51
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
0 answers

validateMenuItem on NSViewController

Is it possible to have validateMenuItem work with NSViewControllers? The docs say NSViewController is a subclass of NSResponder so I would think it would participate in the responder chain, but I have never been able to get it to work. I can make…
jsd
  • 7,673
  • 5
  • 27
  • 47
9
votes
7 answers

Remove 'Start Dictation' and 'Special Characters' from menu

To enable Copy and Paste in my Cocoa app, I added two new menu items (copy and paste) to the menu and dragged the selector from each item to the first responder (copy and paste). However, two extra items show up below the Copy and Paste menu items:…
user1884325
  • 2,530
  • 1
  • 30
  • 49
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
7 answers

Custom NSView in NSMenuItem not receiving mouse events

I have an NSMenu popping out of an NSStatusItem using popUpStatusItemMenu. These NSMenuItems show a bunch of different links, and each one is connected with setAction: to the openLink: method of a target. This arrangement has been working fine for…
Dennis
  • 1,215
  • 1
  • 12
  • 15
9
votes
2 answers

How do I route menu actions to an NSViewController inside a window?

I have a menu item inside the main app menu and I’d like to route its action to a view controller (NSViewController). The interface hierarchy looks like this: There’s a main app window controller by an NSWindowController. Inside the window there’s a…
zoul
  • 102,279
  • 44
  • 260
  • 354
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
3 answers

NSMenuItem not being enabled?

I have an NSMenuItem called history which resides in a NSMenu called menu. When my program starts history doesn't have a submenu so its disabled. Then at some point, I need a submenu for history, so I create it, make it a submenu of history. An…
user635064
  • 6,219
  • 12
  • 54
  • 100
8
votes
1 answer

NSToolbarItem validation in relevant controller

I have an NSToolbarItem with an NSButton as its view and an NSMenuItem in the main menu. Both have the same action, which is sent to the first responder, not to a particular target. That method is ultimately implemented in a subclass of…
Eitot
  • 186
  • 1
  • 11
8
votes
3 answers

How do I make a Menu Bar (NSPopover) App active when clicking on the menu button?

I have an app that sits in the menu bar, and when you click on the button it presents an NSPopover. That all works fine, but I want an NSSearchField to become the first responder, so a user can then type straight in the box. However, if the app was…
Christopher Hannah
  • 1,718
  • 2
  • 14
  • 23
1
2
3
22 23