1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.54">
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: 12.0px Helvetica
; color: #0000bf}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
; min-height: 17.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; min-height: 14.0px}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
; min-height: 14.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 9.0px Monaco
}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
; min-height: 17.0px}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
24 p
.p15
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
25 p
.p16
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
}
26 p
.p17
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #007300}
27 p
.p18
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
28 p
.p19
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
29 span
.s1
{font: 18.0px Helvetica
}
30 span
.s2
{color: #000000}
31 span
.s3
{text-decoration: underline
}
32 span
.s4
{color: #0000bf}
33 span
.s5
{font: 9.0px Monaco
}
34 span
.s6
{color: #606060}
35 span
.s7
{font: 14.0px Helvetica
}
36 span
.s8
{color: #007300}
37 span
.Apple-tab-span
{white-space:pre
}
41 <p class=
"p1"><span class=
"s1"><b>SCNumberBox
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>a box for displaying and editing numerical values
</b><span class=
"s1"><b><span class=
"Apple-tab-span"> </span></b></span></p>
42 <p class=
"p2"><br></p>
43 <p class=
"p3"><span class=
"s2"><b>Inherits from:
</b><a href=
"../../Core/Object.html"><b>Object
</b></a><b> :
</b><a href=
"SCView.html"><b>SCView
</b></a><b> :
</b><a href=
"SCStaticTextBase.html"><b>SCStaticTextBase
</b></a></span></p>
44 <p class=
"p2"><br></p>
45 <p class=
"p3"><span class=
"s2"><b>See also:
</b> <a href=
"SCTextField.html"><span class=
"s3">SCTextField
</span></a></span></p>
46 <p class=
"p2"><br></p>
47 <p class=
"p4"><b>Some Important Issues Regarding SCNumberBox
</b></p>
48 <p class=
"p1">Whatever is entered into the number box is converted to a
<a href=
"../../Math/Float.html"><span class=
"s4">Float
</span></a> upon hitting return or enter. You can also use exponential notation for entering a number, e.g.
"2.1e-2" will be converted to
0.02. Drag and drop accepts a
<a href=
"../../Math/Number.html"><span class=
"s4">Number
</span></a>.
<span class=
"Apple-converted-space"> </span>SCNumberBox inherits formatting methods from
<a href=
"SCStaticTextBase.html"><span class=
"s4">SCStaticTextBase
</span></a>.
<span class=
"Apple-converted-space"> </span></p>
49 <p class=
"p2"><br></p>
50 <p class=
"p1">By default,
<b>scroll
</b> is set to to true, and you can use mouse scrolling in the SCNumberBox by step. By default, the shift, ctrl, and alt keys will modify the arrow stepping and scrolling by
100x,
10x, or
0.1x repectively, though you can customize this by setting
<b>shift_scale, ctrl_scale,
</b>or
<b> alt_scale.
</b>.
<span class=
"Apple-converted-space"> </span></p>
51 <p class=
"p2"><br></p>
52 <p class=
"p2"><br></p>
53 <p class=
"p4"><b>Creation / Class Methods
</b></p>
54 <p class=
"p5"><br></p>
55 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>*new (parent, bounds)
</b></p>
56 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
57 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>parent
</b>- The parent view.
</p>
58 <p class=
"p8"><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=
"s4">Rect
</span></a>, or a
<a href=
"../../Geometry/Point.html"><span class=
"s4">Point
</span></a> indicating width@height.
</p>
59 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
60 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">(
</span></p>
61 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w =
<span class=
"s4">Window
</span>(
<span class=
"s6">"NumberBox Example"</span>,
<span class=
"s4">Rect
</span>(
100,
500,
400,
120));
</p>
62 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b =
<span class=
"Apple-tab-span"> </span><span class=
"s4">NumberBox
</span>(w,
<span class=
"s4">Rect
</span>(
150,
10,
100,
20));
</p>
63 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.value = rrand(
1,
15);
</p>
64 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.action = {
<span class=
"s4">arg
</span> numb; numb.value.postln; };
</p>
65 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.front
</p>
66 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
67 <p class=
"p11"><br></p>
68 <p class=
"p12"><b>Accessing Instance and Class Variables
</b></p>
69 <p class=
"p13"><br></p>
70 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>value
</b></p>
71 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>value_ (val)
</b></p>
72 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
73 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Sets/gets the number box value. This will
<b>not
</b> evaluate the function assigned to
<b>action
</b> (see
<a href=
"SCView.html"><span class=
"s4">SCView
</span></a>).
</p>
74 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>val
</b>- A numerical value. You can also use exponential notation for entering a number, e.g.
2.1e-2 will be converted to
0.02.
</p>
75 <p class=
"p11"><br></p>
76 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>valueAction_ (val)
</b></p>
77 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
78 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Sets the number box to display
<b>val
</b>, and evaluates action (see
<a href=
"SCView.html"><span class=
"s4">SCView
</span></a>), if the value has changed.
</p>
79 <p class=
"p6"><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>
80 <p class=
"p11"><br></p>
81 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>step_(val)
</b></p>
82 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>step
</b></p>
83 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
84 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The size of the step for the
<b>increment
</b> and
<b>decrement
</b> methods.
</p>
85 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>val
</b>- An instance of
<a href=
"../../Math/Float.html"><span class=
"s4">Float
</span></a>.
</p>
86 <p class=
"p11"><br></p>
87 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>clipLo_(aFloat)
</b></p>
88 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>clipHi_(aFloat)
</b></p>
89 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>clipLo
</b></p>
90 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>clipHi
</b></p>
91 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
92 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Constrain the receiver's value to clipLo and clipHi.
</p>
93 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>clipLo defaults to -
<span class=
"s4">inf
</span> - no clipping.
</p>
94 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>clipHi defaults to
<span class=
"s4">inf
</span> - no clipping.
</p>
95 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>aFloat
</b>- An instance of
<a href=
"../../Math/Float.html"><span class=
"s4">Float
</span></a>.
</p>
96 <p class=
"p11"><br></p>
97 <p class=
"p12"><b>Mouse click and drag scrolling behavior
</b></p>
98 <p class=
"p7"><br></p>
99 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>scroll_(bool)
</b></p>
100 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>scroll
</b></p>
101 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
102 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Enable/disable the receiver's mouse click and drag scrolling behavior.
</p>
103 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>scroll defaults to true.
<span class=
"Apple-converted-space"> </span></p>
104 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
105 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>scroll_step_(val)
</b></p>
106 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>scroll_step
</b></p>
107 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
108 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The default size of the step for mouse scrolling. This is modified by
<b>shift_scale, ctrl_scale,
</b>and
<b>alt_scale.
</b></p>
109 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>val
</b>- An instance of
<a href=
"../../Math/Float.html"><span class=
"s4">Float
</span></a>.
</p>
110 <p class=
"p11"><br></p>
111 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>shift_scale_(aFloat)
</b></p>
112 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>shift_scale
</b></p>
113 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
114 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>A value for
<b>increment
</b>'s or
<b>decrement
</b>'s zoom argument while mouse scrolling
<span class=
"Apple-converted-space"> </span>or arrow keys, and while the
<b>shift
</b> key is pressed.
<span class=
"Apple-converted-space"> </span></p>
115 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>shift_scale
</b> defaults to
100.
</p>
116 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>aFloat
</b>- An instance of
<a href=
"../../Math/Float.html"><span class=
"s4">Float
</span></a>.
</p>
117 <p class=
"p11"><br></p>
118 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>ctrl_scale_(aFloat)
</b></p>
119 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>ctrl_scale
</b></p>
120 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
121 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>A value for
<b>increment
</b>'s or
<b>decrement
</b>'s zoom argument while mouse scrolling or arrow keys, and while the
<b>ctrl
</b> key is pressed.
<span class=
"Apple-converted-space"> </span></p>
122 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>ctrl_scale
</b> defaults to
10.
</p>
123 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>aFloat
</b>- An instance of
<a href=
"../../Math/Float.html"><span class=
"s4">Float
</span></a>.
</p>
124 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
125 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>alt_scale_(aFloat)
</b></p>
126 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>alt_scale
</b></p>
127 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
128 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>A value for
<b>increment
</b>'s or
<b>decrement
</b>'s zoom argument while mouse scrolling or arrow keys, and while the
<b>alt
</b> key is pressed.
<span class=
"Apple-converted-space"> </span></p>
129 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>ctrl_scale
</b> defaults to
0.1.
</p>
130 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>aFloat
</b>- An instance of
<a href=
"../../Math/Float.html"><span class=
"s4">Float
</span></a>.
</p>
131 <p class=
"p11"><br></p>
132 <p class=
"p12"><b>Customizing Appearance
</b></p>
133 <p class=
"p7"><br></p>
134 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>boxColor
</b></p>
135 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>boxColor_ (color)
</b></p>
136 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
137 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>This has been deprecated. Use
<b>background
</b>/
<b>background_
</b> instead. See
<a href=
"SCView.html"><span class=
"s4">SCView
</span></a>.
</p>
138 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
139 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>normalColor_(arg1)
</b></p>
140 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>normalColor
</b></p>
141 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
142 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>The default is Color.black. You can use the normalColor and the stringColor in combination to indicate if the contents of the box have changed. When you create the box, its string color is the color you set in stringColor. The if you change the box contents, either with the keyboard or with the setter, value_ , then the color changes to normalColor.
<span class=
"Apple-converted-space"> </span></p>
143 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
144 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>arg1
</b>- An instance of
<a href=
"../GUI-Tools/Color.html"><span class=
"s4">Color
</span></a>.
</p>
145 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
146 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</p>
147 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w =
<span class=
"s4">Window
</span>(
<span class=
"s6">"NumberBox Example"</span>,
<span class=
"s4">Rect
</span>(
100,
500,
400,
120));
</p>
148 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b =
<span class=
"Apple-tab-span"> </span><span class=
"s4">NumberBox
</span>(w,
<span class=
"s4">Rect
</span>(
150,
10,
100,
20));
</p>
149 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.value =
5;
</p>
150 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.stringColor=
<span class=
"s4">Color
</span>.black;
</p>
151 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.normalColor=
<span class=
"s4">Color
</span>.green(
0.8);
</p>
152 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.action = {
<span class=
"s4">arg
</span> numb; numb.value.postln; };
</p>
153 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.front
</p>
154 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
155 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
156 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.value =
12;
</p>
157 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
158 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>typingColor_(arg1)
</b></p>
159 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>typingColor
</b></p>
160 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
161 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>The string color while typing a new value in the number box. The default is Color.red.
</p>
162 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>arg1
</b>- An instance of
<a href=
"../GUI-Tools/Color.html"><span class=
"s4">Color
</span></a>.
</p>
163 <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></p>
164 <p class=
"p12"><b>Subclassing and Internal Methods
</b></p>
165 <p class=
"p6"><span class=
"s7"><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>
166 <p class=
"p7"><br></p>
167 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>increment(mul)
</b></p>
168 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
169 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Increments the value of the box by
<b>step
</b>. Called by
<b>defaultKeyDownAction
</b>, but you can call it directly too.
</p>
170 <p class=
"p11"><br></p>
171 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>decrement(mul)
</b></p>
172 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
173 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Decrements the value of the box by
<b>step
</b>. Called by
<b>defaultKeyDownAction
</b>, but you can call it directly too.
</p>
174 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
175 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>keyString_(arg1)
</b></p>
176 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>keyString
</b></p>
177 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
178 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>A
<a href=
"../../Collections/String.html"><span class=
"s4">String
</span></a> containing what the user types into the number box. It is converted to a
<a href=
"../../Math/Float.html"><span class=
"s4">Float
</span></a> upon hitting return or enter. This also allows you to use exponential notation for entering a number, e.g.
2.1e-2 will be converted to
0.021 .
</p>
179 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
180 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>init (argParent, argBounds)
</b></p>
181 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
182 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Overrides the init method of
<a href=
"SCView.html"><span class=
"s4">SCView
</span></a>.
</p>
183 <p class=
"p11"><br></p>
184 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>defaultKeyDownAction (char, modifiers, unicode)
</b></p>
185 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
186 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>The default keydown actions are:
</p>
187 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
188 <p class=
"p6"><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><span class=
"Apple-tab-span"> </span><b>comment
</b></p>
189 <p class=
"p6"><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>enter typed value
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(enter key or cmd-C on Mac OSX )
</p>
190 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>unicode
16rF700,
<span class=
"Apple-tab-span"> </span>increment by
<b>step
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>up arrow
</p>
191 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>unicode
16rF703,
<span class=
"Apple-tab-span"> </span>increment by
<b>step
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>right arrow
</p>
192 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>unicode
16rF701,
<span class=
"Apple-tab-span"> </span>decrement by
<b>step
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>down arrow
</p>
193 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>unicode
16rF702,
<span class=
"Apple-tab-span"> </span>decrement by
<b>step
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>left arrow
<span class=
"Apple-tab-span"> </span></p>
194 <p class=
"p11"><br></p>
195 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>properties
</b></p>
196 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></p>
197 <p class=
"p6"><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=
"s4">SCView
</span></a>.
</p>
198 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
199 <p class=
"p16"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>returns:
</p>
200 <p class=
"p17"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
</span>\bounds
<span class=
"s2">,
</span>\visible
<span class=
"s2">,
</span>\enabled
<span class=
"s2">,
</span>\canFocus
<span class=
"s2">,
</span>\resize
<span class=
"s2">,
</span>\background
<span class=
"s2">,
</span>\minWidth
<span class=
"s2">,
</span>\maxWidth
<span class=
"s2">,
</span>\minHeight
<span class=
"s2">,
</span>\maxHeight
<span class=
"s2">,
</span>\string
<span class=
"s2">,
</span>\font
<span class=
"s2">,
</span>\stringColor
<span class=
"s2">,
</span>\boxColor
<span class=
"s2">,
</span>\focusColor
<span class=
"s2"> ]
</span></p>
201 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
202 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span>defaultGetDrag
</b></p>
203 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
204 <p class=
"p6"><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 SCNumberBox. Returns
<b>object
</b>.asFloat.
</p>
205 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
206 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>defaultCanReceiveDrag
</b></p>
207 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
208 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>The method called by default when attempting to place a drag in this object. By default, SCNumberBox will respond only to drags where the drag contains a
<a href=
"../../Math/Number.html"><span class=
"s4">Number
</span></a>.
</p>
209 <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><span class=
"s5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span></p>
210 <p class=
"p6"><span class=
"Apple-tab-span"> </span><b>defaultReceiveDrag
</b></p>
211 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b></p>
212 <p class=
"p6"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>The default method called when a drag has been received. Performs
<b>valueAction_()
</b> using
<b>currentDrag
</b> as an argument
<span class=
"Apple-tab-span"> </span></p>
213 <p class=
"p12"><b>Examples
</b></p>
214 <p class=
"p15"><br></p>
216 <p class=
"p14"><span class=
"Apple-tab-span"> </span>w =
<span class=
"s4">Window
</span>(
<span class=
"s6">"NumberBox Example"</span>,
<span class=
"s4">Rect
</span>(
100,
500,
400,
120));
</p>
217 <p class=
"p14"><span class=
"Apple-tab-span"> </span>b =
<span class=
"Apple-tab-span"> </span><span class=
"s4">NumberBox
</span>(w,
<span class=
"s4">Rect
</span>(
150,
10,
100,
20));
</p>
218 <p class=
"p14"><span class=
"Apple-tab-span"> </span>b.value = rrand(
1,
15);
</p>
219 <p class=
"p14"><span class=
"Apple-tab-span"> </span>b.action = {
<span class=
"s4">arg
</span> numb; numb.value.postln; };
</p>
220 <p class=
"p14"><span class=
"Apple-tab-span"> </span>w.front
</p>
222 <p class=
"p18">// try these one at time
</p>
223 <p class=
"p18"><span class=
"s2">b.value = rrand(
1,
15) ;
<span class=
"Apple-tab-span"> </span></span>// sets the value but does not perform the action
</p>
224 <p class=
"p18"><span class=
"s2">b.valueAction_(
5);
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// sets the value and performs the action
</p>
225 <p class=
"p18"><span class=
"s2">b.step_(
0.1);
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// change the increment/decrement size for the arrow keys
</p>
226 <p class=
"p18"><span class=
"s2">b.scrollStep=
10;
<span class=
"Apple-converted-space"> </span></span>// change the increment/decrement size for the mosueScrolling
</p>
227 <p class=
"p15"><br></p>
228 <p class=
"p18"><span class=
"s2">b.background_(
</span><span class=
"s4">Color
</span><span class=
"s2">.grey);
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// change the background color of the box
</p>
229 <p class=
"p18"><span class=
"s2">b.typingColor_(
</span><span class=
"s4">Color
</span><span class=
"s2">(
0.3,
1,
0.3));
<span class=
"Apple-tab-span"> </span></span>// change the typing color for the box
</p>
230 <p class=
"p18"><span class=
"s2">b.normalColor_(
</span><span class=
"s4">Color
</span><span class=
"s2">.white);
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// change the normal color for the box. won't change until next value change
</p>
231 <p class=
"p15"><br></p>
232 <p class=
"p14">b.setProperty(
<span class=
"s8">\stringColor
</span>,
<span class=
"s4">Color
</span>.white);
</p>
233 <p class=
"p14">b.setProperty(
<span class=
"s8">\align
</span>,
<span class=
"s8">\center
</span>);
</p>
234 <p class=
"p15"><br></p>
235 <p class=
"p18"><span class=
"s2">b.increment;
</span>// increment or decrement by step
</p>
236 <p class=
"p14">b.decrement;
</p>
237 <p class=
"p15"><br></p>
238 <p class=
"p15"><br></p>
239 <p class=
"p15"><br></p>
240 <p class=
"p18">// change freqency of a playing synth by step using arrow keys
</p>
241 <p class=
"p11"><br></p>
242 <p class=
"p14">(
<span class=
"Apple-tab-span"> </span></p>
243 <p class=
"p14"><span class=
"Apple-tab-span"> </span>s.waitForBoot({
</p>
244 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
245 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>n={
<span class=
"s4">arg
</span> freq=
220;
</p>
246 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> out;
</p>
247 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>out=
<span class=
"s4">SinOsc
</span>.ar(freq,
0,
0.2);
</p>
248 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>8.do{out =
<span class=
"s4">AllpassN
</span>.ar(out,
0.2,
0.02+
0.20.rand,
8)};
</p>
249 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>out;
</p>
250 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>}.play;
</p>
251 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
252 <p class=
"p19"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w =
</span><span class=
"s4">Window
</span><span class=
"s2">(
</span>"Use arrow keys to change the frequency by steps"<span class=
"s2">,
</span><span class=
"s4">Rect
</span><span class=
"s2">(
100,
500,
500,
120));
</span></p>
253 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b =
<span class=
"Apple-tab-span"> </span><span class=
"s4">NumberBox
</span>(w,
<span class=
"s4">Rect
</span>(
200,
10,
100,
20));
</p>
254 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.value =
220;
</p>
255 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.action = {
<span class=
"s4">arg
</span> numb; n.set(
<span class=
"s8">\freq
</span>,numb.value); };
</p>
256 <p class=
"p18"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.step=
55;
</span>//make the step a fraction of the freq
</p>
257 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.focus;
</p>
258 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.front;
</p>
259 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
260 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">CmdPeriod
</span>.doOnce({w.close});
</p>
261 <p class=
"p15"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
262 <p class=
"p14"><span class=
"Apple-tab-span"> </span>});
</p>
264 <p class=
"p15"><br></p>
265 <p class=
"p15"><br></p>
266 <p class=
"p15"><br></p>
267 <p class=
"p15"><br></p>