nsmenu

Main Thread Runloop gets blocked on opening nsmenu

筅森魡賤 提交于 2019-12-31 01:41:27
问题 I have an application for which the UI element includes an NSStatusItem and a menu. Inside my application , I am using NSTask asynchronously to perform some operation and I am using the output obtained using the NSFileHandleReadCompletionNotification to update the menu. But now whenever I click and open the menu , the main runloop goes into NSEventTrackingRunLoopMode and the notification posting fails. So basically with my menu open , no operation takes place on the main thread. Now I found a

Handling NSMenuDelegate menuWillOpen for changing targets

心不动则不痛 提交于 2019-12-24 23:25:40
问题 There are lots of related answers about using menuWillOpen . They all explain that one needs to set the menu's delegate first. This is easy when I have just one target, like a Preferences window or the main application. But what if I have a document based app, and I need to have the active document handle menuWillOpen ? Then the delegate isn't a constant any more. What's the proper way to handle this? Do I have to set the delegate to a single object (like the AppDelegate) and then forward the

When to remove dynamic NSMenuItem's from an NSMenu

北城以北 提交于 2019-12-24 00:59:49
问题 I have an NSMenu which contains a number of dynamic items. These items are created in NSMenuDelegate's menuNeedsUpdate method and are each assigned a representedObject. I'm looking to trim the object graph and hopefully regain a bit of memory when the menu is closed by removing all dynamic items (and having them recreated when the menu is re-opened). The issue I'm having is knowing exactly where and how this should be handled. The documentation states that NSMenu's menuDidClose is not a

NSButton with delayed NSMenu - Objective-C/Cocoa

折月煮酒 提交于 2019-12-22 04:09:32
问题 I want to create an NSButton that sends an action when it is clicked, but when it is pressed for 1 or two seconds it show a NSMenu. Exactly the same as this question here, but since that answer doesn't solve my problem, I decided to ask again. As an example, go to Finder, open a new window, navigate through some folders and then click the back button: you go to the previous folder. Now click and hold the back button: a menu is displayed. I don't know how to do this with a NSPopUpButton . 回答1:

Remove (or customize) 'Search' from help menu

和自甴很熟 提交于 2019-12-21 19:32:14
问题 My app has the default 'Help' menu. I have removed the 'Help' entry and added a Support entry that links to a forum on my website. The help menu nib looks like this: But once I have the app up and running a new menu item has been suck in: How can I make the search go away? (Or even better, how could I make it launch a url with params such as http://mywebsite.com/support?search=XXXXX). 回答1: You're looking for NSUserInterfaceItemSearching protocol. Return a single search result item and use it

Remove (or customize) 'Search' from help menu

前提是你 提交于 2019-12-21 19:29:10
问题 My app has the default 'Help' menu. I have removed the 'Help' entry and added a Support entry that links to a forum on my website. The help menu nib looks like this: But once I have the app up and running a new menu item has been suck in: How can I make the search go away? (Or even better, how could I make it launch a url with params such as http://mywebsite.com/support?search=XXXXX). 回答1: You're looking for NSUserInterfaceItemSearching protocol. Return a single search result item and use it

Remove (or customize) 'Search' from help menu

醉酒当歌 提交于 2019-12-21 19:28:57
问题 My app has the default 'Help' menu. I have removed the 'Help' entry and added a Support entry that links to a forum on my website. The help menu nib looks like this: But once I have the app up and running a new menu item has been suck in: How can I make the search go away? (Or even better, how could I make it launch a url with params such as http://mywebsite.com/support?search=XXXXX). 回答1: You're looking for NSUserInterfaceItemSearching protocol. Return a single search result item and use it

Weird issue with NSMenuItem, custom view and mouseUp:

廉价感情. 提交于 2019-12-21 11:35:12
问题 I'm having a very very strange issue here with a NSMenu. About half the NSMenuItems I use have custom views on them through the setView: method on NSMenuItem. In this custom view I've implemented mouseUp: to catch when the user clicks on the menu item, and this works perfectly the first time I open the menu. The second time though, the mouseUp doesn't get called on any of these menu items if I hold the mouse steady when clicking. However, if I click down, then move the cursor ever so slightly

Weird issue with NSMenuItem, custom view and mouseUp:

拥有回忆 提交于 2019-12-21 11:35:03
问题 I'm having a very very strange issue here with a NSMenu. About half the NSMenuItems I use have custom views on them through the setView: method on NSMenuItem. In this custom view I've implemented mouseUp: to catch when the user clicks on the menu item, and this works perfectly the first time I open the menu. The second time though, the mouseUp doesn't get called on any of these menu items if I hold the mouse steady when clicking. However, if I click down, then move the cursor ever so slightly

How to remove NSMenuItem gap above custom view

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 07:14:23
问题 I was looking for something discussed in following posts. Gap above NSMenuItem custom view. Reverse engineering an NSMenu for a Status Bar Item I tried the carbon code provided by Pierre Bernard initially, i was getting same error "EXC_BAD_ACCESS on the line InstallControlEventHandler" like other had. I play with the code lots and accidently found the solution. I have just replaced the InstallControlEventHandler function call to HIViewInstallEventHandler and everything is working fine. Hope