Removing an old, cherished, yet pointless caveat "This documentation is
[supercollider.git] / Help / GUI / Cocoa-GUI / SCPopUpMenu.html
blobcc21a10866af16473668b2518778719e140e2622
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: 18.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: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #001ee6}
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 0.0px; font: 14.0px Helvetica; min-height: 17.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 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
20 p.p11 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica; min-height: 14.0px}
21 p.p12 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #000000}
22 p.p13 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #606060}
23 p.p14 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco}
24 p.p15 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
25 p.p16 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica; min-height: 17.0px}
26 p.p17 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #8d261b}
27 p.p18 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #007300}
28 p.p19 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
29 p.p20 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
30 p.p21 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
31 p.p22 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
32 p.p23 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
33 p.p24 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
34 span.s1 {font: 12.0px Helvetica}
35 span.s2 {color: #6f7181}
36 span.s3 {color: #485abb}
37 span.s4 {color: #000000}
38 span.s5 {text-decoration: underline}
39 span.s6 {color: #5d67a2}
40 span.s7 {font: 9.0px Monaco}
41 span.s8 {color: #0000bf}
42 span.s9 {color: #0922b2}
43 span.s10 {color: #606060}
44 span.s11 {color: #8d261b}
45 span.s12 {color: #51535f}
46 span.s13 {font: 14.0px Helvetica}
47 span.s14 {color: #6f717e}
48 span.s15 {font: 9.0px Monaco; color: #545663}
49 span.s16 {color: #bf0000}
50 span.Apple-tab-span {white-space:pre}
51 </style>
52 </head>
53 <body>
54 <p class="p1"><b>SCPopUpMenu<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b><span class="s1"><b>a pop up menu</b></span><b><span class="Apple-tab-span"> </span></b></p>
55 <p class="p2"><br></p>
56 <p class="p3"><b>Inherits from: </b><a href="../../Core/Object.html"><span class="s2"><b>Object</b></span></a><b> : </b><a href="SCView.html"><span class="s2"><b>SCView</b></span></a><b> : </b><a href="SCControlView.html"><span class="s3"><b>SCControlView</b></span></a></p>
57 <p class="p2"><br></p>
58 <p class="p4"><span class="s4"><b>See also:</b> <a href="../EZ-GUI/EZPopUpMenu.html"><span class="s5">EZPopUpMenu</span></a></span></p>
59 <p class="p2"><br></p>
60 <p class="p5"><b>Some Important Issues Regarding SCPopUpMenu</b></p>
61 <p class="p6"><br></p>
62 <p class="p7">By default, SCPopUpMenu will respond only to drags where the drag contains a <a href="../../Math/Number.html"><span class="s6">Number</span></a>.</p>
63 <p class="p8"><br></p>
64 <p class="p5"><b>Creation / Class Methods</b></p>
65 <p class="p9"><br></p>
66 <p class="p7"><b><span class="Apple-tab-span"> </span>*new (parent, bounds)</b></p>
67 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
68 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>parent </b>- The parent view.</p>
69 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bounds </b>- An instance of <a href="../../Geometry/Rect.html"><span class="s2">Rect</span></a>, or a <a href="../../Geometry/Point.html"><span class="s2">Point</span></a> indicating width@height.</p>
70 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
71 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">(</span></p>
72 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s8">Window</span>.new.front;</p>
73 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>m = <span class="s8">PopUpMenu</span>(w,<span class="s8">Rect</span>(10,10,180,20));</p>
74 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>m.items = [</span>"linear"<span class="s4">,</span>"exponential"<span class="s4">,</span>"sine"<span class="s4">,</span>"welch"<span class="s4">,</span>"squared"<span class="s4">,</span>"cubed"<span class="s4">];</span></p>
75 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>m.action = { <span class="s8">arg</span> menu;</p>
76 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[menu.value, menu.item].postln;</p>
77 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>};</p>
78 <p class="p14"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>)<span class="Apple-tab-span"> </span></p>
79 <p class="p9"><br></p>
80 <p class="p15"><b>Accessing Instance and Class Variables</b></p>
81 <p class="p16"><br></p>
82 <p class="p7"><b><span class="Apple-tab-span"> </span>items</b></p>
83 <p class="p7"><b><span class="Apple-tab-span"> </span>items_ (array)</b></p>
84 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
85 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>array </b>- An <a href="../../Collections/Array.html"><span class="s2">Array</span></a> of <a href="../../Collections/String.html"><span class="s2">String</span></a>s or <a href="../../Core/Symbol.html"><span class="s2">Symbol</span></a>s, which make up the items in the pop up menu.</p>
86 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
87 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>The underlying OS X graphics system gives special meanings to some characters.</p>
88 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>e.g. :</p>
89 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>- </b>is a divider line</p>
90 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
91 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Also these: <b>&lt; = (</b></p>
92 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
93 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
94 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w=<span class="s9">SCWindow</span>.new.front;</p>
95 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>m = <span class="s9">SCPopUpMenu</span>(w,<span class="s9">Rect</span>(10,10,180,20));</p>
96 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
97 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>m.items = [</p>
98 <p class="p17"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s10">""</span><span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// ignored !</p>
99 <p class="p17"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s10">" "</span><span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// displays as a blank</p>
100 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"1 absolute"<span class="s4">,</span></p>
101 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"-replaced by a divider"<span class="s4">, <span class="Apple-tab-span"> </span></span><span class="s11">// starting with a -</span></p>
102 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"3 relative"<span class="s4">,</span></p>
103 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
104 <p class="p17"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s10">"4 fore &lt;= aft"</span><span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// fore aft ( &lt;= disappears )</p>
105 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"5 fore &lt;hello aft"<span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s11">// fore ello aft</span></p>
106 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"6 something -&gt; else"<span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s11">// ok</span></p>
107 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
108 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"7 fore hello aft"<span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s11">// fore hello aft</span></p>
109 <p class="p17"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s10">"8 fore -hello aft"</span><span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// fore -hello aft (one - )</p>
110 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"9 fore -&lt;hello aft"<span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s11">// fore ello aft</span></p>
111 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
112 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"10 something (else)"<span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s11">// item greyed out</span></p>
113 <p class="p17"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s10">"11 something \(else)"</span><span class="s4">,<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// item still greyed out</p>
114 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"12 something [else]"<span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s11">// ok</span></p>
115 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"13 something {else}"<span class="s4">, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s11">// ok</span></p>
116 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
117 <p class="p13"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"14 something | else"<span class="s4"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s11">// ok</span></p>
118 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
119 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>];</p>
120 <p class="p14"><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>
121 <p class="p9"><br></p>
122 <p class="p9"><br></p>
123 <p class="p7"><span class="Apple-tab-span"> </span><b>item</b></p>
124 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
125 <p class="p14"><span class="s1"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns </span>items.at(<span class="s12">this</span>.value)</p>
126 <p class="p8"><span class="Apple-tab-span"> </span></p>
127 <p class="p7"><b><span class="Apple-tab-span"> </span>value</b></p>
128 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
129 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns the index of the currently chosen item. This will <b>not</b> do the <b>action</b>.</p>
130 <p class="p8"><br></p>
131 <p class="p7"><b><span class="Apple-tab-span"> </span>value_ (val)</b></p>
132 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
133 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the menu to display the item at index <b>val</b> of the <b>items</b> array. This will <b>not</b> do the <b>action</b>.</p>
134 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- The index of an item in the <b>items</b> array .</p>
135 <p class="p9"><br></p>
136 <p class="p7"><b><span class="Apple-tab-span"> </span>valueAction_ (val)</b></p>
137 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
138 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the menu to display the item at index <b>val</b> of the <b>items</b> array, and evaluates <b>action</b> (see <a href="SCView.html"><span class="s2">SCView</span></a>), if the value has changed.</p>
139 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- The index of an item in the <b>items</b> array .</p>
140 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
141 <p class="p15"><b>Customizing Appearance</b></p>
142 <p class="p16"><br></p>
143 <p class="p7"><b><span class="Apple-tab-span"> </span>font</b></p>
144 <p class="p7"><b><span class="Apple-tab-span"> </span>font_ (argFont)</b></p>
145 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
146 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the <a href="../Main-GUI/Font.html"><span class="s2">Font</span></a> of the pop up menu. This only changes the font for the displayed item, not for the popped up menu.</p>
147 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>argFont </b>- An instance of <a href="../Main-GUI/Font.html"><span class="s2">Font</span></a>.</p>
148 <p class="p8"><br></p>
149 <p class="p7"><b><span class="Apple-tab-span"> </span>stringColor</b></p>
150 <p class="p7"><b><span class="Apple-tab-span"> </span>stringColor_ (color)</b></p>
151 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
152 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Set the current string <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a> for the display of the menu items . This only changes the string color for the displayed item, not for the popped up menu.</p>
153 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>color </b>- An instance of <a href="../GUI-Tools/Color.html"><span class="s2">Color</span></a>.</p>
154 <p class="p9"><br></p>
155 <p class="p15"><b>Subclassing and Internal Methods</b></p>
156 <p class="p7"><span class="s13"><span class="Apple-tab-span"> </span></span>The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.</p>
157 <p class="p9"><br></p>
158 <p class="p7"><b><span class="Apple-tab-span"> </span>properties</b></p>
159 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
160 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>A list of properties to which this view responds. See <a href="SCView.html"><span class="s14">SCView</span></a>.</p>
161 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
162 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>returns:</p>
163 <p class="p18"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[ </span>\bounds<span class="s4">, </span>\visible<span class="s4">, </span>\enabled<span class="s4">, </span>\canFocus<span class="s4">, </span>\resize<span class="s4">, </span>\background<span class="s4">, </span>\minWidth<span class="s4">, </span>\maxWidth<span class="s4">, </span>\minHeight<span class="s4">, </span>\maxHeight<span class="s4">, </span>\value<span class="s4">, </span>\font<span class="s4">, </span>\items<span class="s4">, </span>\stringColor, \focusColor<span class="s4"> ]<span class="Apple-tab-span"> </span></span></p>
164 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
165 <p class="p7"><b><span class="Apple-tab-span"> </span>defaultGetDrag</b></p>
166 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
167 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>The method called by default when initiating a drag <b>from</b> an SCMenu. Returns the same as <b>value</b>.</p>
168 <p class="p8"><span class="Apple-tab-span"> </span></p>
169 <p class="p7"><span class="Apple-tab-span"> </span><b>defaultCanReceiveDrag</b></p>
170 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
171 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The method called by default when attempting to drop a drag in this object. Returns currentDrag.isNumber, i.e. by default, SCPopUpMenu will respond only to drags where the drag contains a number.<span class="Apple-tab-span"> </span></p>
172 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span></p>
173 <p class="p7"><span class="Apple-tab-span"> </span><b>defaultReceiveDrag</b></p>
174 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
175 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The default method called when a drag has been recieved. Performs <b>valueAction_</b> with the <b>currentDrag</b> as an argument<span class="s15">.</span></p>
176 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
177 <p class="p7"><b><span class="Apple-tab-span"> </span>defaultKeyDownAction (char, modifiers, unicode)</b></p>
178 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
179 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The default keydown actions are:</p>
180 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
181 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>key</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>action</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>comment</b></p>
182 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>" " <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>value + 1<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>space</p>
183 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>\r <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>value + 1</p>
184 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>\n, <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>value + 1<span class="Apple-tab-span"> </span></p>
185 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>3.asAscii,<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>value + 1<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(enter key or cmd-C on Mac OSX )</p>
186 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>unicode 16rF700, <span class="Apple-tab-span"> </span>value - 1<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>up arrow</p>
187 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>unicode 16rF703, <span class="Apple-tab-span"> </span>value + 1<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>right arrow</p>
188 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>unicode 16rF701, <span class="Apple-tab-span"> </span>value + 1<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>down arrow</p>
189 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>unicode 16rF702, <span class="Apple-tab-span"> </span>value - 1<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>left arrow</p>
190 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
191 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>All of these are done with <b>action</b>.</p>
192 <p class="p9"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
193 <p class="p15"><b>Examples</b></p>
194 <p class="p19">(</p>
195 <p class="p20"><span class="s4"><span class="Apple-tab-span"> </span>w = </span><span class="s8">Window</span><span class="s4">.new(</span>"The Eightfold Path"<span class="s4">).front;</span></p>
196 <p class="p21"><span class="Apple-tab-span"> </span>m = <span class="s8">PopUpMenu</span>(w,<span class="s8">Rect</span>(10,10,180,20));</p>
197 <p class="p22"><br></p>
198 <p class="p21"><span class="Apple-tab-span"> </span>m.items = [</p>
199 <p class="p20"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"right view"<span class="s4">,</span>"right thinking"<span class="s4">,</span>"right mindfulness"<span class="s4">,</span>"right speech"<span class="s4">,</span></p>
200 <p class="p20"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"right action"<span class="s4">,</span>"right diligence"<span class="s4">,</span>"right concentration"<span class="s4">,</span>"right livelihood"</p>
201 <p class="p21"><span class="Apple-tab-span"> </span>];</p>
202 <p class="p22"><span class="Apple-tab-span"> </span></p>
203 <p class="p23"><span class="s4"><span class="Apple-tab-span"> </span>m.background_(</span><span class="s8">Color</span><span class="s4">.white.alpha_(0.2)); </span>// only changes the look of displayed item</p>
204 <p class="p23"><span class="s4"><span class="Apple-tab-span"> </span>m.stringColor_(</span><span class="s8">Color</span><span class="s4">.white); <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// only changes the look of displayed item</p>
205 <p class="p23"><span class="s4"><span class="Apple-tab-span"> </span>m.font_(</span><span class="s8">Font</span><span class="s4">(</span><span class="s10">"Courier"</span><span class="s4">, 13)); <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// only changes the look of displayed item</p>
206 <p class="p21"><span class="Apple-tab-span"> </span>m.action = { <span class="s8">arg</span> menu;</p>
207 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[menu.value, menu.item].postln;<span class="Apple-tab-span"> </span></p>
208 <p class="p21"><span class="Apple-tab-span"> </span>};</p>
209 <p class="p21">)</p>
210 <p class="p22"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
211 <p class="p23"><span class="s4">m.value; <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// returns the index of the current item;</p>
212 <p class="p23"><span class="s4">m.item;<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// returns the String or Symbol of the current item<span class="Apple-tab-span"> </span></p>
213 <p class="p22"><span class="Apple-tab-span"> </span></p>
214 <p class="p23"><span class="s4">m.value_(2); <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// changes the displayed item, but does not evaluate the action</p>
215 <p class="p23"><span class="s4">m.valueAction_(3); </span>// evaluates the action.</p>
216 <p class="p22"><br></p>
217 <p class="p22"><br></p>
218 <p class="p23">// Play different Functions</p>
219 <p class="p22"><br></p>
220 <p class="p21">(</p>
221 <p class="p21">s.waitForBoot({</p>
222 <p class="p22"><br></p>
223 <p class="p21"><span class="Apple-tab-span"> </span><span class="s8">var</span> w,menu,snd,funcs,b;</p>
224 <p class="p22"><span class="Apple-tab-span"> </span></p>
225 <p class="p21"><span class="Apple-tab-span"> </span>w=<span class="s8">Window</span>.new.front;</p>
226 <p class="p22"><span class="Apple-tab-span"> </span></p>
227 <p class="p21"><span class="Apple-tab-span"> </span>menu=<span class="s8">PopUpMenu</span>(w,<span class="s8">Rect</span>(10,10,90,20))</p>
228 <p class="p20"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.items_([</span>"Sine"<span class="s4"> , </span>"Saw"<span class="s4"> , </span>"Noise"<span class="s4"> , </span>"Pulse"<span class="s4">]);</span></p>
229 <p class="p22"><span class="Apple-tab-span"> </span></p>
230 <p class="p21"><span class="Apple-tab-span"> </span>funcs=[ {<span class="s8">SinOsc</span>.ar(440,0,0.3)} , {<span class="s8">Saw</span>.ar(440,0.3)} , {<span class="s8">WhiteNoise</span>.ar(0.3)} , {<span class="s8">Pulse</span>.ar(440,0.2,0.3)} ];</p>
231 <p class="p22"><span class="Apple-tab-span"> </span></p>
232 <p class="p21"><span class="Apple-tab-span"> </span>b=<span class="s8">Button</span>(w,<span class="s8">Rect</span>(110,10,180,20))</p>
233 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.states_([[<span class="s10">"play"</span>,<span class="s8">Color</span>.black,<span class="s8">Color</span>.green]])</p>
234 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.mouseDownAction_({</p>
235 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>snd = funcs.at(menu.value).play;<span class="Apple-tab-span"> </span></p>
236 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>})</p>
237 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.action_({ <span class="s8">arg</span> butt, mod;</p>
238 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>snd.free;</p>
239 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>});</p>
240 <p class="p22"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
241 <p class="p21"><span class="Apple-tab-span"> </span>w.front;</p>
242 <p class="p22"><span class="Apple-tab-span"> </span></p>
243 <p class="p23"><span class="s4"><span class="Apple-tab-span"> </span>p=</span><span class="s8">CmdPeriod</span><span class="s4">.add({b.value_(0)});</span>// set button to 0 on hitting Cmd-period</p>
244 <p class="p21"><span class="Apple-tab-span"> </span>w.onClose_{ snd.free; <span class="s8">CmdPeriod</span>.removeAll };<span class="s16">// clean up when window is closed</span></p>
245 <p class="p22"><br></p>
246 <p class="p21">})</p>
247 <p class="p21">)</p>
248 <p class="p22"><br></p>
249 <p class="p24"><br></p>
250 <p class="p24"><br></p>
251 <p class="p24"><br></p>
252 </body>
253 </html>