Removing an old, cherished, yet pointless caveat "This documentation is
[supercollider.git] / Help / GUI / Cocoa-GUI / CocoaMenuItem.html
blob215daf12dfce2b206a42cd7de38145c678ea6a90
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="949.43">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #001bec}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
17 p.p8 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
19 p.p10 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ae1a19}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0016bd}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
23 p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
24 span.s1 {font: 18.0px Helvetica}
25 span.s2 {color: #001dfd}
26 span.s3 {color: #000000}
27 span.s4 {text-decoration: underline}
28 span.s5 {color: #606060}
29 span.s6 {color: #0016bd}
30 span.s7 {color: #ae1a19}
31 span.Apple-tab-span {white-space:pre}
32 </style>
33 </head>
34 <body>
35 <p class="p1"><span class="s1"><b>CocoaMenuItem<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>abstract superclass of OSX Menu Items</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
36 <p class="p2"><br></p>
37 <p class="p1"><b>Inherits from: </b><a href="../../Core/Object.html"><span class="s2"><b>Object</b></span></a></p>
38 <p class="p3"><br></p>
39 <p class="p1">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 <b>*add</b> (see below) allows one to easily add items to a default 'Library' menu.</p>
40 <p class="p2"><br></p>
41 <p class="p4"><span class="s3"><b>See also:</b> <a href="SCMenuItem.html"><span class="s4">SCMenuItem</span></a>, <a href="SCMenuGroup.html"><span class="s4">SCMenuGroup</span></a>, <a href="SCMenuSeparator.html"><span class="s4">SCMenuSeparator</span></a></span></p>
42 <p class="p2"><br></p>
43 <p class="p5"><b>Class Methods</b></p>
44 <p class="p6"><br></p>
45 <p class="p7"><b><span class="Apple-tab-span"> </span>*clearCustomItems</b></p>
46 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
47 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Clear all custom menu items.</p>
48 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
49 <p class="p7"><span class="Apple-tab-span"> </span><b>*default</b></p>
50 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
51 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns the 'Library' menu, creating it if necessary.</p>
52 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
53 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
54 <p class="p7"><b><span class="Apple-tab-span"> </span>*add (names, action)</b></p>
55 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
56 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Add an item to the Library menu. The Library menu will be created automatically if needed.</p>
57 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>names </b>- An Array of Strings indicating the menu path to this item.</p>
58 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>action </b>- A Function that will be evaluated when this item is selected.</p>
59 <p class="p6"><br></p>
60 <p class="p6"><br></p>
61 <p class="p10"><b>Instance Methods</b></p>
62 <p class="p8"><span class="Apple-tab-span"> </span></p>
63 <p class="p7"><b><span class="Apple-tab-span"> </span>action_(actionFunc)</b></p>
64 <p class="p7"><b><span class="Apple-tab-span"> </span>action</b></p>
65 <p class="p8"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
66 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Get or set this item's action. This is a <a href="../../Core/Kernel/Function.html"><span class="s2">Function</span></a> that will be evaluated when this item is selected.</p>
67 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
68 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
69 <p class="p7"><b><span class="Apple-tab-span"> </span>state_ (bool)</b></p>
70 <p class="p7"><b><span class="Apple-tab-span"> </span>state</b></p>
71 <p class="p8"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
72 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Get or set this item's state. If <b>bool</b> is true a check mark is displayed next to the item.</p>
73 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
74 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
75 <p class="p7"><b><span class="Apple-tab-span"> </span>remove</b></p>
76 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
77 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Remove the receiver and its children (if any).</p>
78 <p class="p6"><br></p>
79 <p class="p6"><br></p>
80 <p class="p7"><b><span class="Apple-tab-span"> </span>enabled_ (bool)</b></p>
81 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
82 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Enable or disable this menu item.</p>
83 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bool </b>- A <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> indicating whether this item should be enabled or disabled.</p>
84 <p class="p6"><br></p>
85 <p class="p6"><br></p>
86 <p class="p7"><b><span class="Apple-tab-span"> </span>setShortCut (string, alt, ctrl)</b></p>
87 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
88 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Set the keyboard shortcut for this item. The Cmd key is assumed.</p>
89 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>string </b>- A <a href="../../Collections/String.html"><span class="s2">String</span></a> indicating the character for this shortcut.</p>
90 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>alt </b>- A <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> indicating whether the alt key is included in this shortcut. Default value is false.</p>
91 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>ctrl </b>- A <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a> indicating whether the ctrl key is included in this shortcut. Default value is false.</p>
92 <p class="p6"><br></p>
93 <p class="p6"><br></p>
94 <p class="p7"><b><span class="Apple-tab-span"> </span>doAction</b></p>
95 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
96 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Evaluate the receiver's action function.</p>
97 <p class="p8"><br></p>
98 <p class="p6"><br></p>
99 <p class="p6"><br></p>
100 <p class="p10"><b>Examples</b></p>
101 <p class="p3"><br></p>
102 <p class="p11">// Simple example</p>
103 <p class="p12"><span class="s3">g = </span>SCMenuGroup<span class="s3">(</span>nil<span class="s3">, </span><span class="s5">"stuff"</span><span class="s3">, 10);</span></p>
104 <p class="p13">i = <span class="s6">SCMenuItem</span>(g, <span class="s5">"foo"</span>);</p>
105 <p class="p13">j = <span class="s6">SCMenuItem</span>(g, <span class="s5">"bar"</span>);</p>
106 <p class="p13">j.action = {<span class="s5">"bar!!"</span>.postln};</p>
107 <p class="p11"><span class="s3">k = </span><span class="s6">SCMenuSeparator</span><span class="s3">(g, 1); </span>// add a separator</p>
108 <p class="p13">i.enabled = <span class="s6">false</span>;</p>
109 <p class="p13">j.state = <span class="s6">true</span>;</p>
110 <p class="p13">j.setShortCut(<span class="s5">"$"</span>, <span class="s6">true</span>, <span class="s6">true</span>); <span class="s7">// Cmd-ctrl-alt-$</span></p>
111 <p class="p2"><br></p>
112 <p class="p11">// using *add<span class="Apple-tab-span"> </span></p>
113 <p class="p14"><span class="s6">CocoaMenuItem</span><span class="s3">.add([</span>"hallo"<span class="s3">, </span>"world"<span class="s3">], { </span>"hallo menu"<span class="s3">.postln });</span></p>
114 <p class="p14"><span class="s6">CocoaMenuItem</span><span class="s3">.add([</span>"hallo"<span class="s3">, </span>"world"<span class="s3">, </span>"here"<span class="s3">], { </span>"hallo here"<span class="s3">.postln }); </span><span class="s7">// fails correctly</span></p>
115 <p class="p14"><span class="s6">CocoaMenuItem</span><span class="s3">.add([</span>"mellow"<span class="s3">, </span>"world"<span class="s3">, </span>"here"<span class="s3">], { </span>"mellow here"<span class="s3">.postln }); </span><span class="s7">// works.</span></p>
116 <p class="p13"><span class="s6">CocoaMenuItem</span>.add([<span class="s5">"hallo"</span>, <span class="s5">"thought"</span>], { <span class="s5">"hallo world"</span>.scramble.postln });</p>
117 <p class="p3"><br></p>
118 <p class="p13"><span class="s6">CocoaMenuItem</span>.clearCustomItems;</p>
119 <p class="p3"><span class="Apple-tab-span"> </span></p>
120 <p class="p3"><br></p>
121 <p class="p3"><br></p>
122 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
123 </body>
124 </html>