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
3
votes
1 answer

NSMenuItem number bubble?

I have seen something like this: in a Menulet on the right of menu items and I can't figure out how to do it. Can anyone elaborate? Thank you!
Aaru
  • 57
  • 5
3
votes
1 answer

Control NSMenuItem inset/padding?

Is it possible to control the inset or padding for NSMenuItems? I.e. for a menu used in my NSPopupButton I'd like to remove the left padding (normally used for the checkbox) and add some padding after the text. Can this be achieved (with public…
cacau
  • 3,606
  • 3
  • 21
  • 42
3
votes
3 answers

An NSMenuItem's view (instance of an NSView subclass) isn't highlighting on hover

I need to use a custom NSView subclass to draw some content, but it isn't drawing as highlighted when the user hovers and it doesn't dismiss the NSMenu when the user clicks on it. Any ideas? Edit So using -drawRect: and [[self enclosingMenuItem]…
Alexsander Akers
  • 15,967
  • 12
  • 58
  • 83
3
votes
0 answers

Cocoa: How to get textual representation for key equivalent like in menus?

I was wondering if there's a simple way of getting textual representation of key equivalents (that can be shown to user, like in menus)? E.g.: suppose I have the key code (virtual or unichar, doesn't matter) and modifiers mask. How do I convert…
DenisL
  • 51
  • 5
3
votes
2 answers

Exactly matching the background of a selected NSMenuItem

I am creating a custom view for an NSMenuItem. In order to draw the background when selected, I adapted a couple of lines from the CustomMenus sample. The CustomMenus sample has: [[NSColor alternateSelectedControlColor] set]; …
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
3
votes
1 answer

NSTextField in NSMenuItem

Hi am writing small app for posting twitts on twitter.com I manage to create statusbar icon next to clock and battery monitor, but now I am stacked... I wanted to add menu item text area max length of 140 chars, (4-5 rows text input field) something…
Matt Harasymczuk
  • 1,728
  • 2
  • 21
  • 29
3
votes
1 answer

NSMenuDelegate not called for submenu in NSMenuItem created by another NSMenuDelegate

I have an NSStatusItem with an NSMenu that has a delegate. This delegate dynamically updates the menu based on a few factors. So per the documentation, to quickly update the menu, I use the method: - (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem…
Joe Mizzi
  • 236
  • 2
  • 8
3
votes
1 answer

Mac OSX NSStatusItem with Custom NSMenu/MenuItems AND Drag And Drop functionality

I am trying to create a Mac Application that has an NSStatusItem icon in the Status Bar. The status bar icon should support file drag and drop and must also show a menu when clicked. The problem is that I have managed to achieve both functionalities…
Shumais Ul Haq
  • 1,427
  • 1
  • 15
  • 26
3
votes
2 answers

Display Model's Data in NSMenuItem

I'd like to display some data of my model within a status bar menu. So, I bound my entity-object to the title of an NSMenuItem: [self.statusMenu setAutoenablesItems:NO]; NSMenuItem * exportMenuItem = [[NSMenuItem alloc] init]; …
martn_st
  • 2,576
  • 1
  • 24
  • 30
3
votes
2 answers

How to draw my own key equivalents in NSMenuItem?

I would need something this owner drawn tab completition key equivalents in my own code. Like TextMate does in this example. I heared that the menu drawing is Carbon based but I don't hope it is such a huge hack. But whatever I tried and wherever I…
Lothar
  • 12,537
  • 6
  • 72
  • 121
3
votes
0 answers

NSPopover relative to NSMenuItem

I'm working on an OSX application which uses a NSMenu to display content. I'd like to make a NSPopover appear when an NSMenuItem is highlighted, but I'm stucked with the "showRelativeToRect:ofView:preferredEdge:" part as I don't have a relative view…
Romain Pouclet
  • 864
  • 2
  • 8
  • 17
3
votes
1 answer

Ugly character in NSMenuItem's key equivalent

In my app's main menu I have a menu item that I'd like to set to the shortcut alt+"minus sign". I was able to set the key equivalent in IB, and it triggers as expected, but it's really ugly when running the app: Even though in Interface Builder…
DrummerB
  • 39,814
  • 12
  • 105
  • 142
2
votes
2 answers

Getting NSMenuItem of NSMenu tree by title

I have an NSMenu (let's say the Main Menu), with lots of NSMenus in it, and NSMenuItems at different levels. I want to be able to get the NSMenuItem instance specifying the tree path (with the title of the corresponding NSMenus/NSMenuItems in…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
2
votes
2 answers

How to create a custom NSMenuItem

Well, I have quite a basic question which I can't seem to find an answer to. I followed this guide to create a StatusBar menu, which works great... However, I would like to add a custom NSMenuItem containing custom stuff. As example such as the…
Paul Peelen
  • 10,073
  • 15
  • 85
  • 168
2
votes
0 answers

How to make the NSMenuItem's position just below New Folder item in FinderSync?

I override the menu(for menuKind: FIMenuKind) shows in the following: override func menu(for menuKind: FIMenuKind) -> NSMenu { let menu = NSMenu(title: "") let menuItem = NSMenuItem(title: "❤️", action: nil, keyEquivalent: "") …
Huang Runhua
  • 146
  • 6