nsmenu

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

半腔热情 提交于 2019-12-18 12:42:30
问题 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

How i can get the Application Menu in Cocoa

夙愿已清 提交于 2019-12-17 18:28:45
问题 How can I get the NSMenu or NSMenuItem for the application menu (the one in the menu bar next to the apple menu). It seems to be automatically created and independent from the NSMenu I set via NSApplication setMainMenu. By the way: I'm building my complete application without Xcode, so please no InterfaceBuilder tips. PS: MacOSX 10.5 回答1: Without IB, you can access the menu using the NSApplication's mainMenu: NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu]; NSMenu *appMenu = [

Reverse engineering an NSMenu for a Status Bar Item

烂漫一生 提交于 2019-12-17 17:54:09
问题 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

Get default font name in Cocoa for NSMenuItem?

社会主义新天地 提交于 2019-12-13 13:19:34
问题 I am using NSAttributed NSString in my NSMenuItem, but it's Font is changed as compare to default font, I wants to use default font for Attributed string. Can any one explain, how to find or fetch the default Font for NSMenuItems. Right now I am using this : NSDictionary *attributes = @{ NSFontAttributeName: [NSFont fontWithName:@"Helvetica" size:14], NSForegroundColorAttributeName: [NSColor blackColor], NSParagraphStyleAttributeName:paragraphStyle }; Thanks 回答1: To get the default font of an

NSStatusBar menu bar icon NSMenu leaking CFData

◇◆丶佛笑我妖孽 提交于 2019-12-13 05:24:32
问题 I have a weird data leak and hope someone can explain what is going wrong here. The minimal working example project is as follows: Create a new Objective-C macOS project (Cocoa-App). Delete everything except Info.plist and main.m In Info.plist do: Delete the entry Main nib file base name . Change Principal class to "AppHook". Add LSUIElement and set it to YES . Next, change main.m to: #import <Cocoa/Cocoa.h> #import "AppHook.h" int main(int argc, const char * argv[]) { [[AppHook

How to retrieve the current selection of an NSPopUpButtonCell?

拥有回忆 提交于 2019-12-13 02:08:31
问题 I am using an NSPopUpButtonCell in an NSTableView . The popup button has a binding to an NSArray property offered by the ApplicationDelegate . When I select a menu item of the popup button I expect to retrieve the current selection or its index . I added an IBAction to being informed and also set up an NSMenuDelegate . Both return index = 0 at all times. // indexOfSelectedItem is always 0. NSInteger indexOfSelectedItem = [m_popUpButtonCell indexOfSelectedItem]; I created an example project

OSX System menubar not working in JavaFX

只愿长相守 提交于 2019-12-12 04:20:04
问题 I was trying to use NSMenuFX from https://github.com/codecentric/NSMenuFX to make a JavaFX app use the MacOS System MenuBar, and it didn't work because of this method returning always false . Toolkit.getToolkit().getSystemMenu().isSupported() The method is from the package : com.sun.javafx.tk.Toolkit . Going deeper in the code I've found that Toolkit.getToolkit().getSystemMenu().isSupported() calls a method from com.sun.glass.ui.Application that returns always false too. protected boolean

How to create NSButton with delayed NSMenu?

只谈情不闲聊 提交于 2019-12-12 02:09:20
问题 In Cocoa i want to create an nsbutton with delayed menu. i.e., When clicked it should call the action method and when kept in pressed state for 2 seconds it should display a nsmenu. It is similar to "Build Active Target" button present in Xcode toolbar. Regards, Dhanaraj. 回答1: It's a NSPopUpButton.. Here is how I create it in my app. NSToolbarItem* item = [[[NSToolbarItem alloc] initWithItemIdentifier:identifier] autorelease]; [item setLabel:label]; [item setPaletteLabel:label]; [item

NSStatusBar drag & drop with menu

不想你离开。 提交于 2019-12-11 11:53:43
问题 I'm familiar with the technique described here: Drag and Drop with NSStatusItem to make an NSStatusBar item that can handle file drag & drop. What is the proper method for having a status bar item that supports both drag & drop and regular menu interactions, much like the Cloudapp icon does. I want users to be able to left click the NSStatusItem to see the normal menu listing as well as allow for file drag and drop functionality. It seems to me like I have to write all my own click handler

Customize NSMenu (like Apple's Dock right click Menu)?

只谈情不闲聊 提交于 2019-12-11 03:13:43
问题 Is there any way to customize NSMenu appearances, for example, its transparency, background color or foreground color using public API"S (like Apple's Dock right click Menu) ?? After lots of search i have found some code where they are using private API's for making the menu dark !!! 回答1: I think you'll have better luck if you just use a custom view which you code to look however you want and to behave like a menu. Apple provides a sample project, CustomMenus, which illustrates that technique