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
8
votes
2 answers

What is the purpose of the NSMenuItem's tag attribute?

Can I use the item's tag attribute to store a special key/ID or is it meant for something else? Example of intended use: - (void)awakeFromNib { [self.popup addItemWithTitle: [NSString stringWithFormat: @"dummy title" ]]; [[self.popup…
Davorin
  • 1,160
  • 15
  • 31
8
votes
2 answers

How to change NSMenuItem Title (Login to Logout)

Im surprised that this hasn't already been asked: But how does one go about changing the NSMenuItem title in a NSStatusBar menu. When a user logs in I want the menu item to say logout. I have tried creating an outlet to modify my NSMenuItem as a…
urbanrider
  • 231
  • 5
  • 14
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
7
votes
2 answers

Best way to wire up NSMenuItems from Interface Builder?

So I've spent some time checking out CocoaDev, reading the Cocoa docs on NSMenuItems, and doing some tests in Interface Builder. In my application I have an application menu ([NSApp mainMenu]) designed in Interface Builder. I see three potential…
Chris Hill
  • 1,914
  • 1
  • 16
  • 24
7
votes
1 answer

Correct way to setup target/action for NSMenuItem in Cocoa?

I'm having some real difficulty with some initial Cocoa programming I am carrying out. Essentially, I have an NSStatusBar item with an NSMenu attached as the menu. The menu has a single NMMenuItem. In IB I have connected the NSMenuItem to an…
Edwardr
  • 2,906
  • 3
  • 27
  • 30
7
votes
5 answers

set titles of items in my app's main menu?

I am trying to change the titles of some of the items in my Cocoa app's main menu. I have tried setting them both within IB and also programmatically from my app's applicationDidFinishLaunchingWithOptions: method. Either way, the title property of…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
7
votes
3 answers

Using NSProgressIndicator inside an NSMenuItem

I'm trying to use a NSProgressIndicator (indeterminate) inside of a statusbar-menu. I'm using an NSView-object as view for the menuitem, and then subviews the progress indicator to display it. But whenever i try to call the startAnimation: for the…
Henrik
  • 582
  • 1
  • 3
  • 15
7
votes
2 answers

Finder Sync: Sender passed to action is different instance of NSMenuItem

I have implemented a Finder Sync extension according to the provided sample given from Apple. After clicking on the newly created contextual menu item the according action sampleAction is executed. Unfortunately the sender passed to the method does…
Joe Inner
  • 1,450
  • 1
  • 10
  • 14
7
votes
1 answer

How to draw an inline style label (or button) inside NSMenuItem

When App Store has updates, it shows an inline style element in the menu item, like '1 new' in the screenshot below: Another place we can see this kind of menu is 10.10 Yosemite's share menu. When you install any app that adds a new share…
James Chen
  • 10,794
  • 1
  • 41
  • 38
7
votes
1 answer

Alternative Menu Items in NSMenu

I have an NSMenu that contains NSMenuItems with custom views. I want it so that when the alt button is pressed, the menu items would change part of their look (through their view). I found setAlternative in the NSMenuItem docs, however, in…
Nick Paulson
  • 111
  • 1
  • 5
7
votes
2 answers

NSMenuItem Key Equivalent not working when menu is hidden

I have an NSMenu in Interface Builder that is connected to an NSTableView's menu outlet. I want to assign Key Equivalents to the items in this menu so the user doesn't have to right click, but they don't work unless the menu is visible (defeating…
colincameron
  • 2,696
  • 4
  • 23
  • 46
7
votes
3 answers

cocoa: menu bar item with backspace as key equivalent

I would like to set the key equivalent of a menu bar item in IB to the backspace key (delete left of the cursor), but for some reason this doesn't seem to work. I can assign all kinds of keys to it, such as CMD+Backspace, or fn+Backspace (delete…
mtmurdock
  • 12,756
  • 21
  • 65
  • 108
6
votes
1 answer

Creating NSMenuItems programmatically in MonoMac

I'm trying to programmatically add a menu to my MonoMac application. I've opened up the MainMenu.xib and removed all NSMenuItem from the MainMenu control. I'm adding the following code into my FinishedLaunching override: var fileMenuItem = new…
sohum
  • 3,207
  • 2
  • 39
  • 63
6
votes
0 answers

NSMenuItem with custom view in macOS 11 Big Sur

macOS 11 Big Sur in its current iteration (beta 1 through beta 6) has a bug/feature that makes it hard to have NSMenuItem with the custom view. Specifically, the custom view of an item won't get a draw(dirtyRect:) call when the menu item gets…
Vitalii Vashchenko
  • 1,777
  • 1
  • 13
  • 23
6
votes
2 answers

NSMenuItem's NSView not highlighting in submenu

I have an NSStatusItem that displays an NSMenu full of NSView subclasses. I override drawRect: in my NSView subclass to implement highlighting in the NSMenu and everything works fine in the root menu, but for some reason it doesn't work in submenus…
edc1591
  • 10,146
  • 6
  • 40
  • 63
1 2
3
22 23