nsmenuitem

Getting a particular menu item from MainMenu

I have a nib (winA.xib) that contains a window. My app delegate contains an NSWindowController subclass called WinAController. WinAController has a property (NSMenu *mainMenu) that I want to point to the MainMenu. I have set it after I instantiate WinAController with this code: WinAController = [[WinAController alloc] initWithWindo...

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] isHighlighted] I'm able to tell whether or not I need to draw the view as highlighted and a...

Ellipsizing an NSMenuItem's title to the width of the menu

I want to programatically change an NSMenuItem's title, but ellipsize it so that this modification never causes the menu to increase in width. how can i do this? ...

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! ...

Selecting the first item in a popUpContextMenu

I work on a very keyboard intensive application. Both hands on the keyboard. No hands on the mouse. A user can, via the keyboard, popup a context menu, select an item and finally hit enter. [NSMenu popUpContextMenu] displays the menu without highlighting any item. The user will have to press arrow_down one time in order to highlight th...

Programmatically adding glyphs (delete key, backspace, space, etc) to menu item

It used to be that in Carbon you could use SetMenuItemKeyGlyph. What's the alternative under 10.6? Will I need to use undocumented goodness or...? Thanks ...

How force NSMenuItem to redraw?

Hi, I'm implementing a custom status bar menu, which has a custom view with NSSearchField. I'm updating number of menu items according to search results. The number of menu items is changed as user types in the NSSearchField. I've noticed, that if number of results stays the same, items titles are not updated (redrawn). How do I force t...

NSMenuItem Hidden binding issue

I have an NSMenuItem which I have bound to an NSUserDefaults boolean value in IB like so: When bMenuHidden is true, I would like my NSMenuItem to be hidden, and vice versa. This works as expected under Snow Leopard. However, Leopard struggles in some cases. In particular: my NSMenuItem is visible upon first launching the application, ...

NSMenuItem -setTarget: Does it retain the target?

NSMenuItem -setTarget: Does it retain the target, or should one explicitly retain it? I've seen conflicting docs on this. I know of retainArguments in NSInvocation, but I'm not sure this applies to NSMenuItem as it doesn't inherit from NSInvocation. ...

Cocoa custom view for NSMenuItem

Hi folks, I am developing a small app that display the active mounts in a menu in the NSStatusBar. So far it looks like this: I want to add an eject button to the right of each menu item (like the left bar in the Finder). I know that I have to create a custom view and set it with the setView: method. The problem is that I am very new...

NSMenuDelegate questions

I have an NSMenu which contains both static and dynamically created NSMenuItem's (static meaning NSMenuItem's created in Interface Builder, dynamic meaning NSMenuItem's created at run-time). Although I'm developing on 10.6, my application also offers 10.5 support. My menu consists of a number of dynamic NSMenuItem's which contain subme...

Interface Builder Bug?

I have a cocoa program that I have I am writing on a 10.6 system, but targeting to 10.5. On the 10.6 system, it works fine. However, when I run it on the 10.5 machine, I get: The sender of menu item actions is now the NSMenuItem, not an NSMatrix. A menu item action method appears to be trying to send the NSMatrix method 'acc...

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 = [menu addItemWithTitle:@"Start" action:@selector(start:) keyEquivalent:@""]; ...

how to set focus on NSMenu (make it get key events)?

I have a status menu with a NSSearchField and menu items. When search field is active and user presses up & down arrows, I'd like to start menu tracking, that is that the user will be able to move with arrow keys between menu items. I can catch moveUp and moveDown selectors. How can I cause the menu to become a key responder? Thanks, N...

Sync state of two NSMenuItems

Hi, I have two NSMenus with the same NSMenuItems. Only one NSMenuItem in its NSMenu should be selected. (Kind of like an NSMatrix). So I connected each NSMenuItem to the same action and added an iVar for the index of the item with the NSOnState. Inside the method I set the state of the item with the old index to NSOffState and the new o...

Displaying custom/arbitrary controls in an NSMenu

How can I Display an NSTextField or an NSProgressIndicator within an NSMenu? I'm looking to do something similar to the Spotlight icon menu, or the Help menu of most applications. ...

Loading NSView subclass from a XIB

I need to use a custom view into a NSMenuItem. I've created a new view XIB and customized the view in it. How can I load that view and set it in the NSMenuItem using the setView: method? UPDATE: I've found a solution but now the menu item with the custom view doesn't highlight on mouse over. Ho can I solve this problem? ...

How to know which NSTableView opened a Contextual Menu?

Hi!, I have 5 NSTableView's instances that have the same contextual menu. When I get the message that the menu has been clicked I need to know which table sent it. I've checked the NSMenu documentation but I don't seem to find a way to check which of the tables opened the menu.. I'm thinking of subclassing NSTableView and send a message...

Reverse engineering an NSMenu for a Status Bar Item

Hello all, I'm want to create a menu for a status bar item like the one seen in Tapbot's PastebotSync application: Does anyone have any ideas how to achieve the custom area at the top of the menu which is flush with the top? I've tried/thought of a few potential ways of doing it: Standard NSMenuItem with a view - isn't flush with ...