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
37
votes
3 answers

How does Apple update the Airport menu while it is open? (How to change NSMenu when it is already open)

I've got a statusbar item that pops open an NSMenu, and I have a delegate set and it's hooked up correctly (-(void)menuNeedsUpdate:(NSMenu *)menu works fine). That said, that method is setup to be called before the menu is displayed, I need to…
Aaron
  • 4,634
  • 1
  • 27
  • 43
29
votes
2 answers

How to access the system selected menu item blue color?

I'm working on an app that has a custom NSView on a NSStatusBar which performs all of the drawing when the user clicks it. But here's the problem, the color I'm currently drawing as the view's background color is not the same as the system blue…
Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76
25
votes
1 answer

disabled NSMenuItem

I programmatically create an NSMenuItem and it is disabled. If I override the validateMenuItem: method and return YES for all items, the menu item works fine. Why would it not be enabled when I tell the menu to autoEnableItems and dont override the…
joels
  • 7,249
  • 11
  • 53
  • 94
23
votes
8 answers

Cannot seem to setEnabled:NO on NSMenuItem

I have subclassed NSMenu and connected a bunch of NSMenuItem's via Interface Builder. I have tested via the debugger to see that they really get initialized. The menu is set to not auto enable items. Still when I set any of my NSMenuItem's to…
Christoffer
  • 25,035
  • 18
  • 53
  • 77
19
votes
4 answers

Highlighting a NSMenuItem with a custom view?

I have created a simple NSStatusBar with a NSMenu set as the menu. I have also added a few NSMenuItems to this menu, which work fine (including selectors and highlighting) but as soon as I add a custom view (setView:) no highlighting…
rdougan
  • 7,217
  • 2
  • 34
  • 63
19
votes
1 answer

Gap above NSMenuItem custom view

I am using the setView: method on an NSMenuItem to set a custom view. In this custom view there is an image which takes the whole of the view. The NSMenuItem with this custom view is the first in the menu but the problem is it doesn't sit flush with…
Joshua
  • 15,200
  • 21
  • 100
  • 172
15
votes
1 answer

Creating NSMenu with NSMenuItems in it, programmatically?

First, I'd like to point out that this question is probably already asked, I just couldn't find any answers from them. So, I'm programmatically trying to create a NSMenu and NSMenuItem to the main bar, so fe. NSMenu would be File and then it would…
user1632861
15
votes
3 answers

menu item is enabled, but still grayed out

I have a menu with several items created in interface builder. It looks fine there and 'enabled' is checked. But when I run the application, all menu items are grayed out. I've checked isEnabled, it returns true. Also, menu items created…
Nikita Rybak
  • 67,365
  • 22
  • 157
  • 181
14
votes
1 answer

Update NSMenuItem while the host menu is shown

I have an NSMenuItem that I need to update to show a progress (like Time machine does with it's backup). The problem is that when I set a new title on that NSMenuItem and the title is not changing. It is in fact changing when I close and reopen the…
gcamp
  • 14,622
  • 4
  • 54
  • 85
14
votes
1 answer

Connecting Menu Items in Document Based Applications

I've already asked a couple questions on this topic, and haven't really received a real answer on how to do it (it actually received the "Tumbleweed Badge" lol). I have a document based application (meaning the Menu.Xib is separate from…
Zakman411
  • 1,764
  • 3
  • 22
  • 45
12
votes
1 answer

How do I set the sender on a NSMenuItem's action?

The Apple documentation says that the sender passed to the NSMenuItem's action can be set to some custom object, but I can't seem to figure out how to do this. Is there a method I'm not seeing someplace in the documentation?
Jeff Barger
  • 1,241
  • 1
  • 13
  • 19
11
votes
1 answer

NSMenuItem with custom view doesn't receive mouse events

I'm working on a menu bar app, and I'm setting a custom view using NSMenuItem's view property. The view displays ok, but I'm unable to receive any kind of mouse click events for menu items that have open submenus. In this screenshot, I've added a…
SteveB
  • 351
  • 1
  • 4
  • 15
11
votes
2 answers

adding NSSubmenu item in NSMenuItem

I want to add a drop down menu in one of the entries in the NSMenu Item. (eg. If you click on the Battery indicator on Finder bar, it has an option for Show->Icon,Time,Percentage). Now I add a MenuItem using the following code: menuItem =…
ZionKing
  • 326
  • 1
  • 4
  • 16
11
votes
3 answers

NSMenu programmatically select item

I'm writing a plugin for application - custom keyboard shortcut. I can traverse through its views. I need to open popup menu, select item in it, then open its submenu and select some item in submenu. For now I'm only able to open top popup menu by…
cody
  • 3,233
  • 1
  • 22
  • 25
11
votes
5 answers

NSMenuItem KeyEquivalent " "(space) bug

I want to set key equivalent " "(space) without any modifiers for NSMenuItem (in App Main Menu). As follows from documentation: For example, in an application that plays media, the Play command may be mapped to just “ ” (space), without the command…
Kira
  • 509
  • 5
  • 14
1
2 3
22 23