3 summary:: A view displaying non-editable text
7 A view displaying non-editable text
21 The text displayed by the view.
27 If link::#-setBoth:: is true, setting this variable also sets link::#-string:: to the value interpreted link::Classes/Object#-asString#as String::.
30 Any object, typically one which makes sense to display as a string, such as a Float.
33 A variable stating whether setting link::#-object:: will also set link::#-string::.
38 SUBSECTION:: Appearance
41 The alignment of the displayed text.
44 One of the following symbols: \centered, \left, or \right.
47 The font used to display the text.
53 The color used to display the text.
59 Setting this variable colors the whole area occupied by the view under the text with the given color.
67 subsection:: Basic Example
72 a = StaticText(w, Rect(10, 10, 200, 20));
73 a.string = "Rolof's Rolex";
76 // adjust look , alignment and content
77 a.background=Color.grey;
79 a.font = Font("Monaco", 11);
80 a.string = "Your Rolex";
84 subsection:: Monitoring Values in a Synth
89 w = Window("Frequency Monitor", Rect(200, Window.screenBounds.height-200,300,150)).front;
91 a = StaticText(w, Rect(45, 10, 200, 20)).background_(Color.rand);
93 a.string = " Current Frequency ";
95 Button.new(w, Rect(45, 70, 200, 20)).states_([["close",Color.black,Color.rand]]).action_({w.close});
99 b=Bus.new(\control,0,1);
101 q=SynthDef(\Docs_FreqMonitor, {var freq,snd;
102 freq=LFNoise0.ar(2, 400, 650);
103 snd=SinOsc.ar(freq,0,0.2);
105 Out.kr(b.index,freq); // output the frequency to a control bus
109 { // Set the value of the StaticText to the value in the control bus.
110 // Setting GUI values is asynchronous, so you must use .defer in the system clock.
111 // Also you must check if the window is still open, since Routine will continue for at least
112 // one step after you close the window.
113 b.get( {arg v; {w.isClosed.not.if{ a.string= " Current Frequency: "++v.round(0.01)}; }.defer} );
121 CmdPeriod.doOnce({w.close});
122 w.onClose={r.stop; q.free; b.free }; //clean up if the window closes
128 subsection:: Dynamic Text
132 w = Window.new.front;
133 w.view.background=Color.white;
134 a = Array.fill(20, {StaticText(w, Rect(w.bounds.extent.x.rand, w.bounds.extent.y.rand, 160, 16))
135 .string_("Rolof's Rolex".scramble)
137 .stringColor_(Color.rand)
149 thisThread.randSeed_(1284);
151 // setting GUI values is asynchronous, so you must use .defer
152 {item.bounds = Rect(5+w.bounds.extent.x.rand * (cos(i*0.01)).abs,
153 w.bounds.extent.y.rand * sin(i*0.01),
158 CmdPeriod.doOnce({w.close});
159 w.onClose_({r.stop});