How do I get a text field or a search field within a menu like OS X’s help menu (no need for the special styling)? I don’t think I’ve seen this done anywhere.
I’m pretty sure that what you see in the help menu is actually a window made to look like a menu.
Ok, that would make sense. How would I get a window into a menu item?
EDIT: So I’ve got my custom view, complete with text field. Just need to link it to the menu somehow?
If you look in the NSMenu docs at the companion guide, “Application Menu and Pop-up List Programming Topics”, you will see “Views in Menu Items” as the last topic. I translated the sample code they had there to ASOC, whhich gives you this:
script MenuViewsAppDelegate property parent : class "NSObject" property custView : missing value --This is my custom view on applicationWillFinishLaunching_(aNotification) set menuBarItem to current application's NSMenuItem's alloc()'s initWithTitle_action_keyEquivalent_("Custom", "menuBarAction:", "") set newMenu to current application's NSMenu's alloc()'s initWithTitle_("Custom") menuBarItem's setSubmenu_(newMenu) current application's NSApp's mainMenu()'s insertItem_atIndex_(menuBarItem, 3) set newItem to current application's NSMenuItem's alloc()'s initWithTitle_action_keyEquivalent_("Custom Item 1", "menuItem1Action:", "") newItem's setView_(custView) --Here is where you add your view newItem's setTarget_(me) newMenu's addItem_(newItem) end applicationWillFinishLaunching_ end script
Perfect. Thank you so much. Now that I see how to implement it, I see how how it all comes together. Thanks again!