nsmenu

NSMenuDelegate not called for submenu in NSMenuItem created by another NSMenuDelegate

杀马特。学长 韩版系。学妹 提交于 2019-12-10 21:09:43
问题 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 *)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel; At the appropriate time in this method I call the following: NSMenu *submenu = [[NSMenu alloc] init]; SomeSubmenuDelegate *submenuDelegate = [[SomeSubmenuDelegate alloc] init];

Cocoa application menu - how to recreate?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 16:11:45
问题 Inside the MainMenu.xib I deleted the default Main Menu that automatically gives you the application menu (along with the File/Edit/Format/View/Window/Help menus). What are the steps I need to take to add this back into my application? 回答1: I would create a new application then copy just the Main Menu back into your MainMenu.xib 来源: https://stackoverflow.com/questions/6300256/cocoa-application-menu-how-to-recreate

Updating an NSmenu from an asynchronous NSURLConnection

回眸只為那壹抹淺笑 提交于 2019-12-10 15:39:27
问题 I am writing a little systray application that fetches data from an API and updates its menu accordingly, and am having trouble with updating the menu while it's open. I don't even know where to start, so let's start with the beginning. I have a custom PNLinksLoader class whose responsibility is to fetch the data and parse it: - (void)loadLinks:(id)sender { // instance variable used by the NSXMLParserDelegate implementation to store data links = [NSMutableArray array]; [NSURLConnection

NSMenuDelegate methods not called for contextual menu

江枫思渺然 提交于 2019-12-10 10:45:30
问题 I have a Document based application. I want to add a contextual menu that displays context-sensitive info when the user right-clicks selected text in an NSTextView. I have followed the advice in the Apple documentation and Added an NSMenu as a root object in my XIB file. Connected the NSMenu instance to the menu outlet of the NSTextView. Connected an IBAction to the NSMenuItem inside the NSMenu. So far so good. Every thing works as expected: the menu item appears and the action is called when

How Can I Show NSMenu at Mouse Cursor?

喜你入骨 提交于 2019-12-09 13:30:24
问题 I am working on an app where I want to show an NSMenu "context menu" next to the current mouse location. At this point, I know how to trigger the command from the WebView to show the context menu, I just can't seem to get the menu to show up at the correct placement on the screen. It seems like my coordinates are inverted vertically from what I need. This seems like such a simple problem, but I have spent a good bit of time trying to best a "best practices" solution. Do I need to figure out

Adding item to NSMenu with action selector preset

坚强是说给别人听的谎言 提交于 2019-12-08 07:32:32
问题 I'm new to Obj-C/Cocoa programming, and I'm having an issue trying to dynamically add menu items to an NSMenu instance and have the items action selector already set upon insertion. I can, add the dynamic menu items fine, but the action selector doesn't trigger when the item is clicked via the menu. The first line below is the line of code I am using to add the menu item. You can set I'm setting the action:(SEL)aSelector to the "openEchowavesURL" function. This function is in the same

How to place Horizontal Slider in NSMenu (Swift 3, Xcode 8)

感情迁移 提交于 2019-12-07 17:35:45
问题 As of macOS Sierra the volume menu bar item provides a horizontal slider item to change the system's volume: I'd like to adopt this concept for my own application and came up with the following class: import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! let statusItem = NSStatusBar.system().statusItem(withLength: -2) func applicationDidFinishLaunching(_ aNotification: Notification) { let menu = NSMenu() let menuItem =

NSTextfield + NSMenu and first responder

杀马特。学长 韩版系。学妹 提交于 2019-12-07 04:21:21
问题 I'm trying to implement my own autocomplemention system (result is pull from an sqlite database) I've set up a NSTextField and the appropriate delegate. Each time the text in the NSTextField change, it call - (void)controlTextDidChange:(NSNotification *)aNotification method It work fine, in this method I build a menu programtically and finally I call/show it with that code: NSRect frame = [address frame]; NSPoint menuOrigin = [[address superview] convertPoint:NSMakePoint(frame.origin.x, frame

Adding item to NSMenu with action selector preset

≯℡__Kan透↙ 提交于 2019-12-06 14:49:12
I'm new to Obj-C/Cocoa programming, and I'm having an issue trying to dynamically add menu items to an NSMenu instance and have the items action selector already set upon insertion. I can, add the dynamic menu items fine, but the action selector doesn't trigger when the item is clicked via the menu. The first line below is the line of code I am using to add the menu item. You can set I'm setting the action:(SEL)aSelector to the "openEchowavesURL" function. This function is in the same controller class file and I've included the function definition below. Am I just calling the wrong selector

No callback when clicking menu item

[亡魂溺海] 提交于 2019-12-06 12:35:34
问题 I'm trying to implement a simple context menu in my FinderSync extension. I built the following using some examples, and my problem is that the callback is never called when I click the menu item. Source code: ContextMenuHelper.h #import <Foundation/Foundation.h> #include "FinderSync.h" @interface ContextMenuHelper : NSObject + (NSMenu *)buildMenu; @end ContextMenuHelper.m #import "ContextMenuHelper.h" #define SharedContextMenuTarget [ContextMenuTarget sharedInstance] @interface