cmake build system: visiblity support for clang
[supercollider.git] / Help / Control / CmdPeriod.html
blobd95227913690832aa611591286eebcb3fd483920
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: 13.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 Monaco; min-height: 16.0px}
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 0.0px; font: 9.0px Monaco}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0023b7}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9e201b}
20 span.s1 {font: 18.0px Helvetica}
21 span.s2 {color: #0023b7}
22 span.s3 {color: #606060}
23 span.s4 {color: #000000}
24 span.s5 {color: #3c6d12}
25 span.Apple-tab-span {white-space:pre}
26 </style>
27 </head>
28 <body>
29 <p class="p1"><span class="s1"><b>CmdPeriod<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>register objects to be cleared when Cmd-. is pressed</b></p>
30 <p class="p2"><br></p>
31 <p class="p3"><b>Superclass: Object</b></p>
32 <p class="p2"><br></p>
33 <p class="p3">CmdPeriod allows you to register objects to perform an action when the user presses Cmd-. These objects must implement a method called -cmdPeriod which performs the necessary tasks. (You can add such a method in your custom classes.) Note that since <a href="../Core/Kernel/Function.html"><span class="s2">Function</span></a><b> </b>implements -cmdPeriod as a synonym for -value, it is possible to register any function (and thus any arbitrary code) for evaluation when Cmd-. is pressed.</p>
34 <p class="p2"><br></p>
35 <p class="p4"><br></p>
36 <p class="p5"><b>Class Methods</b></p>
37 <p class="p2"><br></p>
38 <p class="p3"><b>*add(object)</b></p>
39 <p class="p2"><br></p>
40 <p class="p3">Registers an object to be cleared when Cmd-. is pressed. This object will stay registered until it is explicitly removed, and will thus respond to additional presses of Cmd-.<span class="Apple-converted-space"> </span></p>
41 <p class="p2"><br></p>
42 <p class="p3"><b>*remove(object)</b></p>
43 <p class="p2"><br></p>
44 <p class="p3">Removes an object that was previously registered.</p>
45 <p class="p2"><br></p>
46 <p class="p3"><b>*removeAll</b></p>
47 <p class="p2"><br></p>
48 <p class="p3">Removes all objects that have been registered.</p>
49 <p class="p2"><br></p>
50 <p class="p3"><b>*doOnce(object)</b></p>
51 <p class="p2"><br></p>
52 <p class="p3">Registers an Object o be evaluated once, and then unregistered.</p>
53 <p class="p2"><br></p>
54 <p class="p3"><b>*objects</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>return the list of objects that are called when CmdPeriod is evaluated.</p>
55 <p class="p2"><br></p>
56 <p class="p3"><b>*objects_(array)</b><span class="Apple-tab-span"> </span>set the list of objects that are called when CmdPeriod is evaluated.</p>
57 <p class="p2"><br></p>
58 <p class="p3"><b>*era</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>number of times CmdPeriod has been called since startup.</p>
59 <p class="p4"><br></p>
60 <p class="p4"><br></p>
61 <p class="p4"><br></p>
62 <p class="p5"><b>Examples</b></p>
63 <p class="p6"><br></p>
64 <p class="p7">(</p>
65 <p class="p7">f = {<span class="s3">"foo"</span>.postln };</p>
66 <p class="p7">g = {<span class="s3">"bar"</span>.postln };</p>
67 <p class="p8">CmdPeriod<span class="s4">.add(f);</span></p>
68 <p class="p8">CmdPeriod<span class="s4">.add(g);</span></p>
69 <p class="p7">)</p>
70 <p class="p9"><br></p>
71 <p class="p10">// Now press Cmd-.</p>
72 <p class="p9"><br></p>
73 <p class="p7"><span class="s2">CmdPeriod</span>.remove(g);</p>
74 <p class="p9"><br></p>
75 <p class="p10">// Now press Cmd-. Only f executes</p>
76 <p class="p9"><br></p>
77 <p class="p10"><span class="s2">CmdPeriod</span><span class="s4">.remove(f); </span>// must explicitly cleanup</p>
78 <p class="p9"><br></p>
79 <p class="p9"><br></p>
80 <p class="p10">// Now press Cmd-.</p>
81 <p class="p9"><br></p>
82 <p class="p10"><span class="s2">CmdPeriod</span><span class="s4">.add(g); </span>// one object is added only once.</p>
83 <p class="p10"><span class="s2">CmdPeriod</span><span class="s4">.add(g); </span>// one object is added only once.</p>
84 <p class="p9"><br></p>
85 <p class="p9"><br></p>
86 <p class="p10">// Now press Cmd-.</p>
87 <p class="p9"><br></p>
88 <p class="p10">// remove it again.</p>
89 <p class="p7"><span class="s2">CmdPeriod</span>.remove(g);</p>
90 <p class="p9"><br></p>
91 <p class="p9"><br></p>
92 <p class="p10">// note that often you want to automatically remove the function once it is evaluated</p>
93 <p class="p10">// instead of</p>
94 <p class="p9"><br></p>
95 <p class="p7">f = { <span class="s3">"foo"</span>.postln; <span class="s2">CmdPeriod</span>.remove(f) };</p>
96 <p class="p8">CmdPeriod<span class="s4">.add(f);</span></p>
97 <p class="p9"><br></p>
98 <p class="p10">// you can write:</p>
99 <p class="p9"><br></p>
100 <p class="p7"><span class="s2">CmdPeriod</span>.doOnce { <span class="s3">"foo"</span>.postln }</p>
101 <p class="p9"><br></p>
102 <p class="p10">// a typical example:</p>
103 <p class="p7">(</p>
104 <p class="p7">w = <span class="s2">Window</span>.new(<span class="s3">"close on cmd-."</span>).front;</p>
105 <p class="p7"><span class="s2">CmdPeriod</span>.doOnce { w.close };</p>
106 <p class="p7">)</p>
107 <p class="p9"><br></p>
108 <p class="p9"><br></p>
109 <p class="p10">// in some cases you might need to defer the function by a short amount of time</p>
110 <p class="p7">a = { <span class="s2">Synth</span>(<span class="s5">\default</span>)};</p>
111 <p class="p7">a.value;</p>
112 <p class="p7"><span class="s2">CmdPeriod</span>.add({{a.value}.defer(0.01)});</p>
113 <p class="p9"><br></p>
114 <p class="p10">// remove all<span class="Apple-converted-space"> </span></p>
115 <p class="p7"><span class="s2">CmdPeriod</span>.removeAll</p>
116 <p class="p9"><br></p>
117 </body>
118 </html>