2 summary:: Abstract superclass of OSX Menu Items
4 related:: Classes/SCMenuItem, Classes/SCMenuGroup, Classes/SCMenuSeparator
7 CocoaMenuItem represents a menu item or sub menu in the application menu. This is an abstract class. Generally you will deal with the subclasses SCMenuItem, SCMenuGroup, and SCMenuSeparator, but the convenience method *add (see below) allows one to easily add items to a default 'Library' menu.
12 method:: clearCustomItems
13 Clear all custom menu items.
16 Returns the 'Library' menu, creating it if necessary.
19 Add an item to the Library menu. The Library menu will be created automatically if needed.
21 An link::Classes/Array:: of link::Classes/String::s indicating the menu path to this item.
23 A link::Classes/Function:: that will be evaluated when this item is selected.
29 Get or set this item's action. This is a Function that will be evaluated when this item is selected.
33 Get or set this item's state. If bool is true a check mark is displayed next to the item.
37 Remove the receiver and its children (if any).
40 Enable or disable this menu item.
42 A link::Classes/Boolean:: indicating whether this item should be enabled or disabled.
45 Set the keyboard shortcut for this item. The Cmd key is assumed.
47 A link::Classes/String:: indicating the character for this shortcut.
49 A link::Classes/Boolean:: indicating whether the alt key is included in this shortcut. Default value is false.
51 A link::Classes/Boolean:: indicating whether the ctrl key is included in this shortcut. Default value is false.
54 Evaluate the receiver's action function.
61 g = SCMenuGroup(nil, "stuff", 10);
62 i = SCMenuItem(g, "foo");
63 j = SCMenuItem(g, "bar");
64 j.action = { "bar!!".postln };
65 k = SCMenuSeparator(g, 1); // add a separator
68 j.setShortCut("$", true, true); // Cmd-ctrl-alt-$
71 CocoaMenuItem.add(["hallo", "world"], { "hallo menu".postln });
72 CocoaMenuItem.add(["hallo", "world", "here"], { "hallo here".postln }); // fails correctly
73 CocoaMenuItem.add(["mellow", "world", "here"], { "mellow here".postln }); // works.
74 CocoaMenuItem.add(["hallo", "thought"], { "hallo world".scramble.postln });
76 CocoaMenuItem.clearCustomItems;