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

NSMenuItem.separator() is a blank space rather than a line

I'm building a Finder extension for OSX, I want to add a separator to the contextMenu of Finder, but I can't see the separator line: The separator I want to add is like this: Here is the related code: let main = NSMenu() let submenu =…
EssExx
  • 49
  • 6
2
votes
0 answers

Custom view for NSMenuItem appearing blank

I've been trying to make a custom view for a NSMenuItem with an image on it. The code below overrides the original view, but without the image. The item appears blank and smaller. This code is only an example! class CustomItemView: NSView { …
Alexandra
  • 39
  • 6
2
votes
0 answers

NSMenuItem actions overriding NSPopUpButton actions

I've noticed an interesting behavior and I wonder if it's something I'm doing wrong. I have an NSPopUpButton with several NSMenuItems on an NSMenu on the NSPopUpButton. When I click the popup button and select an item the action that I've linked to…
JPC
  • 8,096
  • 22
  • 77
  • 110
2
votes
1 answer

How can I get a NSMenuItem from a submenu?

I have a reference to the outermost menu, but I'm trying to get a reference to an NSMenuItem that's nested in a submenu: NSMenuItem* file_menu = [menu itemWithTitle:@"File]; file_menu is obviously a submenu (NSMenu), but I'm not sure how to get an…
James
  • 6,471
  • 11
  • 59
  • 86
2
votes
1 answer

Custom View inside NSMenu Item in SWIFT

I wand to build a two line menu item in a taskbar Swift Application for MacOS, that behaves like a normal menu item, just with additional information. I managed to get the menu and the taskbar application going, but failed with the custom view…
2
votes
0 answers

How to create a NSWindow inside a menulet

I'm creating a menulet application in Xcode 4, and I'm trying to figure out how to display a window that will appear when the menulet icon is clicked. I would hope for the window to be displayed as the normal NSWindow. I have looked at the…
mocall
  • 21
  • 2
2
votes
1 answer

How do I use isAlternative with an NSMenuItem with a customView?

I'm attempting to use the isAlternative property with an NSMenuItem with a custom view. It is not behaving as a standard NSMenuItem without a custom view. How do I get the standard modifier-key toggling behavior when using NSMenuItems with custom…
Ian Gordon
  • 41
  • 3
2
votes
0 answers

NSMenuItem alternate item with no keyboard shortcut

I have a menu item that by default uses app state to trigger its enabled-ness. But in very rare situations (usually during interaction with customer support), we need to allow the user to trigger the same menu even though that app has disabled it.…
2
votes
2 answers

How do I get my menulet to look like this

How do i get this effect with a menulet application. I just want the window effect nothing else. My current app looks like this. please if someone could shed some light it would be appreciated. Thanks.
xMythicx
  • 827
  • 1
  • 11
  • 27
2
votes
1 answer

How do I bind an NSMenuItem to an NSArrayController

How do I bind the enabled state of an NSMenuItem to an NSArrayController's selection? I've tried binding the item's enabled state to the controller's selectedObjects or selectedIndexes and in neither case is the menuitem ever enabled when there are…
2
votes
1 answer

Create NSMenu for NSStatusBar.systemStatusBar programmatically

I'm trying to create a simple menu in the System Status Bar using code only. I'm not receiving any compilation or runtime errors but I see no effect at all. - (void)awakeFromNib { NSMenu *stackMenu = [[NSMenu alloc] initWithTitle:@"Status…
Jeff Swensen
  • 3,513
  • 28
  • 52
2
votes
2 answers

State of NSMenuItem bound to boolean in NSUserDefaults not staying in sync

I have an NSMenuItem titled "Word Wrap" in my main menu (MainMenu.xib). Its value is bound to my shared user defaults controller, also instantiated in the XIB. It also sends the following action when selected: - (IBAction)toggleWordWrap:(id)sender…
alexantd
  • 3,543
  • 3
  • 27
  • 41
2
votes
1 answer

NSMenuItem with attributedTitle not working in macOS 10.12.2 Sierra

I create a menu of file names and modification dates. I align these using an attributed string with a tab stop set to fit the longest file name. This works fine on macOS 10.8-10.11. This is what the menu should look like - on macOS 10.11 and…
MichaelR
  • 1,681
  • 15
  • 28
2
votes
1 answer

Why cannot I open the Preferences from each windows?

I have come across this Cocoa application (source code) that shows a main Window. As long as this window is key it is possible to open the Preferences window from the Main menu as well as by hitting Command-, but when the main window is not key and…
rano
  • 5,616
  • 4
  • 40
  • 66
2
votes
0 answers

Adding NSMenuItems to a NSMenu in code

I have added a menu named Resources to the main menu bar and dragged an outlet named resourcesMenu to the app delegate. When I attempted to add a method addResources.., auto completion suggested: -(void)addResourcesMenu:(NSSet *)objects. Is this…
Carl Carlson
  • 500
  • 4
  • 17