Include a header file required for build on mac 10.4
[supercollider.git] / Help / GUI / GUI-Tools / modifiers.html
blobb6bb508244d8350ff8a57b376303d53d8b1da9fe
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.46">
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: 18.0px Helvetica; min-height: 22.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica; min-height: 14.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #007300}
19 span.s1 {color: #0000bf}
20 span.s2 {color: #000000}
21 span.s3 {color: #606060}
22 span.Apple-tab-span {white-space:pre}
23 </style>
24 </head>
25 <body>
26 <p class="p1"><b>Modifier Keys<span class="Apple-tab-span"> </span></b></p>
27 <p class="p2"><br></p>
28 <p class="p3">An integer bit field indicating the modifier keys in effect. You can examine individual flag settings using the C bitwise AND operator.</p>
29 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
30 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>65536 NSAlphaShiftKeyMask</p>
31 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set if Caps Lock key is pressed.</p>
32 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
33 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>131072 NSShiftKeyMask</p>
34 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set if Shift key is pressed.</p>
35 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
36 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>262144 NSControlKeyMask</p>
37 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set if Control key is pressed.</p>
38 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
39 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>524288 NSAlternateKeyMask</p>
40 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set if Option or Alternate key is pressed.</p>
41 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
42 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>1048576 NSCommandKeyMask</p>
43 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set if Command key is pressed.</p>
44 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
45 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>2097152 NSNumericPadKeyMask</p>
46 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set if any key in the numeric keypad is pressed. The numeric keypad is generally on the right side of the keyboard.</p>
47 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
48 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>4194304 NSHelpKeyMask</p>
49 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set if the Help key is pressed.</p>
50 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
51 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>8388608 NSFunctionKeyMask</p>
52 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Set if any function key is pressed. The function keys include the F keys at the top of most keyboards (F1, F2, and so on) and the navigation keys in the center of most keyboards (Help, Forward Delete, Home, End, Page Up, Page Down, and the arrow keys).</p>
53 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
54 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>arrow keys have an extra modifier value of 10485760</p>
55 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>so for a shift arrow key do a bitwise 'or' with the shift mask:</p>
56 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>10485760 | 131072</p>
57 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>= 10616832 // this is the mask for shift arrow key</p>
58 <p class="p4"><br></p>
59 <p class="p3">Three usage examples, direct and with helper methods</p>
60 <p class="p3"><span class="Apple-tab-span"> </span><b>isCaps, isShift, isCtrl, isAlt, isCmd, isNumPad, isHelp, isFun</b>:</p>
61 <p class="p4"><br></p>
62 <p class="p5">(</p>
63 <p class="p6">w = <span class="s1">Window</span>.new.front; w.addFlowLayout;</p>
64 <p class="p7"><br></p>
65 <p class="p8"><span class="s2"><span class="Apple-tab-span"> </span></span>// direct, using bit field</p>
66 <p class="p6"><span class="s1">Button</span>(w, <span class="s1">Rect</span>(0,0,390,50)).states_([[<span class="s3">"hold shift/alt keys and click"</span>]])</p>
67 <p class="p6"><span class="Apple-tab-span"> </span>.action_ { <span class="s1">|but, mod|</span><span class="Apple-converted-space"> </span></p>
68 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if (mod &amp; 131072 == 131072) { <span class="s3">"shift key was pressed."</span>.postln; };</p>
69 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if (mod &amp; 524288 == 524288) { <span class="s3">"alt key was pressed."</span>.postln; };</p>
70 <p class="p6"><span class="Apple-tab-span"> </span>};</p>
71 <p class="p7"><br></p>
72 <p class="p8"><span class="s2"><span class="Apple-tab-span"> </span></span>// using helper methods</p>
73 <p class="p6"><span class="s1">Button</span>(w, <span class="s1">Rect</span>(0,0,390,50)).states_([[<span class="s3">"hold any mod keys and click"</span>]])</p>
74 <p class="p6"><span class="Apple-tab-span"> </span>.action_ { <span class="s1">|but, mod|</span><span class="Apple-converted-space"> </span></p>
75 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(mod.isCaps) { <span class="s3">"mod pressed: Caps."</span>.postln };</p>
76 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(mod.isShift) { <span class="s3">"mod pressed: Shift."</span>.postln };</p>
77 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(mod.isCtrl) { <span class="s3">"mod pressed: Ctrl."</span>.postln };</p>
78 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(mod.isAlt) { <span class="s3">"mod pressed: Alt."</span>.postln };</p>
79 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(mod.isNumPad) { <span class="s3">"mod pressed: NumPad."</span>.postln };</p>
80 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(mod.isHelp) { <span class="s3">"mod pressed: Help."</span>.postln };</p>
81 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(mod.isFun) { <span class="s3">"mod pressed: Fun."</span>.postln };</p>
82 <p class="p6"><span class="Apple-tab-span"> </span>};</p>
83 <p class="p7"><br></p>
84 <p class="p8"><span class="s2"><span class="Apple-tab-span"> </span></span>// collecting all modifiers</p>
85 <p class="p6"><span class="s1">Button</span>(w, <span class="s1">Rect</span>(0,0,390,50)).states_([[<span class="s3">"hold any mod keys and click"</span>]])</p>
86 <p class="p6"><span class="Apple-tab-span"> </span>.action_ { <span class="s1">|but, mod|</span><span class="Apple-converted-space"> </span></p>
87 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s1">var</span> pressed;</p>
88 <p class="p9"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>#[</span>\isCaps<span class="s2">, </span>\isShift<span class="s2">, </span>\isCtrl<span class="s2">, </span>\isAlt<span class="s2">, </span>\isCmd<span class="s2">, </span>\isNumPad<span class="s2">, </span>\isHelp<span class="s2">, </span>\isFun<span class="s2">].do { </span><span class="s1">|x|</span></p>
89 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(mod.perform(x)) { pressed = pressed.add(x) }</p>
90 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>};</p>
91 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>pressed.postln;</p>
92 <p class="p6"><span class="Apple-tab-span"> </span>};</p>
93 <p class="p5">)</p>
94 </body>
95 </html>