nsmenu

How to update NSMenu while it's open?

ぐ巨炮叔叔 提交于 2019-11-30 20:43:13
I have a NSMenu with dynamically added NSMenuItems. The NSMenu is not refreshing properly while it's kept open. I am calling NSMenu update method in NSEventTrackingRunLoopModes . I have implemented following methods to update NSMenu. - (void)menuNeedsUpdate:(NSMenu *)menu { for (NSInteger index = 0; index < count; index++) [self menu:menu updateItem:[menu itemAtIndex:index] atIndex:index shouldCancel:NO]; } - (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel` - (NSInteger)numberOfItemsInMenu:(NSMenu *)menu I am dynamically

Force NSMenu (nested submenu) update for Main Menu of Cocoa App

跟風遠走 提交于 2019-11-30 07:43:54
I have some submenu inserted as Window item submenu of Main Menu I have an instance of my object (let's assume its class name is MenuController) inherited from NSObject and supports 2 from NSMenuDelegate methods: – numberOfItemsInMenu: – menu:updateItem:atIndex:shouldCancel: This instance added as Blue-Object into NIB for awaking at runtime Object from steps 2-3 configured as delegate for submenu (step 1) Now, I can provide submenu content in runtime. Next, I do following: I can add new items or remove old from an array (inside MenuController which contains menu titles) that mapped to real

Intercepting NSMenu key events

冷暖自知 提交于 2019-11-30 07:42:17
问题 I am making a search field, which opens a NSMenu similar to Finder and Mail The only problem, which drives me crazy, is that i cannot intercept the key events, once the menu is open I even subclassed the NSApplication sendEvent, but was surprised to find out, that during menu, there is no call to Applications sendAction: I subclassed performKeyEquivalent: NSMenu but it is not called - (BOOL)performKeyEquivalent:(NSEvent *)theEvent I am listening for the delegate call on menuHasKeyEquivalent:

How to update NSMenu while it's open?

一个人想着一个人 提交于 2019-11-30 05:45:54
问题 I have a NSMenu with dynamically added NSMenuItems. The NSMenu is not refreshing properly while it's kept open. I am calling NSMenu update method in NSEventTrackingRunLoopModes . I have implemented following methods to update NSMenu. - (void)menuNeedsUpdate:(NSMenu *)menu { for (NSInteger index = 0; index < count; index++) [self menu:menu updateItem:[menu itemAtIndex:index] atIndex:index shouldCancel:NO]; } - (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index

Reverse engineering an NSMenu for a Status Bar Item

99封情书 提交于 2019-11-28 05:35:34
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 the top of the menu Some hack-ish code to place an NSWindow over the area at the top of the menu - not great as it doesn't fade out nicely with the menu when it closes Abandoning an NSMenu entirely and using an NSView instead - haven't tried this yet but I don't really want to

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

社会主义新天地 提交于 2019-11-27 06:30:25
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 listen for that and trigger an asynchronous request, later updating the menu while it is open, and I can't figure out how that's supposed to be done. Thanks :) EDIT Ok, I'm now here: When you click on the menu item (in the status bar), a selector is called that runs an NSTask. I use the notification center to listen for when that task is finished, and

Gap above NSMenuItem custom view

和自甴很熟 提交于 2019-11-27 03:41:45
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 the top of the menu, there is a big gap as you can see here: Why is this happening and how can I stop it? EDIT I am using this code now but I am getting EXC_BAD_ACCESS on the line InstallControlEventHandler . -(void)applicationDidFinishLaunching:(NSNotification *)aNotification { HIViewRef contentView; MenuRef menuRef = [statusMenu carbonMenuRef];

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

筅森魡賤 提交于 2019-11-26 12:00:37
问题 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 listen for that and trigger an asynchronous request, later updating the menu while it is open, and I can\'t figure out how that\'s supposed to be done. Thanks :) EDIT Ok, I\'m now here: When you click on the menu item (in the status bar), a selector

Gap above NSMenuItem custom view

孤街浪徒 提交于 2019-11-26 10:36:11
问题 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 the top of the menu, there is a big gap as you can see here: Why is this happening and how can I stop it? EDIT I am using this code now but I am getting EXC_BAD_ACCESS on the line InstallControlEventHandler . -(void)applicationDidFinishLaunching: