supernova: c++11 compile fix
[supercollider.git] / Help / GUI / Cocoa-GUI / SCTextView.html
blob10a6ec034e8c69c3b48fee4b0a02633a379df0a8
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.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: #0b15e8}
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 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.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 0.0px; font: 9.0px Monaco}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.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; color: #a81914}
24 p.p15 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0910ba}
25 p.p16 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
26 span.s1 {font: 18.0px Helvetica}
27 span.s2 {color: #6c7189}
28 span.s3 {color: #000000}
29 span.s4 {text-decoration: underline}
30 span.s5 {color: #5d66a3}
31 span.s6 {color: #6f717c}
32 span.s7 {color: #0910ba}
33 span.s8 {color: #6f7180}
34 span.s9 {font: 9.0px Monaco}
35 span.s10 {font: 14.0px Helvetica}
36 span.s11 {color: #606060}
37 span.s12 {color: #a81914}
38 span.Apple-tab-span {white-space:pre}
39 </style>
40 </head>
41 <body>
42 <p class="p1"><span class="s1"><b>SCTextView<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>a view in which to display and edit text or code</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
43 <p class="p2"><br></p>
44 <p class="p1"><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></p>
45 <p class="p2"><br></p>
46 <p class="p3"><span class="s3"><b>See also:</b> <a href="SCStaticText.html"><span class="s4">SCStaticText</span></a>, <a href="SCTextField.html"><span class="s4">SCTextField</span></a></span></p>
47 <p class="p2"><br></p>
48 <p class="p4"><b>Some Important Issues Regarding SCTextView</b></p>
49 <p class="p2"><br></p>
50 <p class="p1">While SCTextView allows you to load and display formatted text, and while it understands rtf or html markup, you cannot save formatted text currently. You only have acces to the text-content of the view as a <a href="../../Collections/String.html"><span class="s2">String</span></a>.</p>
51 <p class="p2"><br></p>
52 <p class="p1">By default, SCTextView will recieve drags containing any <a href="../../Core/Object.html"><span class="s5">Object</span></a>, and insert them into the text <b>asString</b>. If you drag a file from the finder onto an SCTextView, it will display the file path in quotation marks.</p>
53 <p class="p2"><br></p>
54 <p class="p4"><b>Creation / Class Methods</b></p>
55 <p class="p5"><br></p>
56 <p class="p6"><b><span class="Apple-tab-span"> </span>*new (parent, bounds)</b></p>
57 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
58 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>parent </b>- The parent view.</p>
59 <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="s6">Rect</span></a>, or a <a href="../../Geometry/Point.html"><span class="s6">Point</span></a> indicating width@height.</p>
60 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
61 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
62 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s7">Window</span>.new.front;</p>
63 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>t = <span class="s7">TextView</span>(w.asView,<span class="s7">Rect</span>(10,10, 380,200))</p>
64 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>.focus(<span class="s7">true</span>);</p>
65 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
66 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
67 <p class="p12"><b>Accessing Instance and Class Variables</b></p>
68 <p class="p13"><br></p>
69 <p class="p6"><b><span class="Apple-tab-span"> </span>string</b></p>
70 <p class="p6"><b><span class="Apple-tab-span"> </span>string_ (str)</b></p>
71 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
72 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The displayed content of the SCView, as a string. For more precise control of the string, see <b>setString</b> below.</p>
73 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>str </b>- An instance of <a href="../../Collections/String.html"><span class="s8">String</span></a>.</p>
74 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
75 <p class="p6"><b><span class="Apple-tab-span"> </span>open (path)</b></p>
76 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
77 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Opens a file from <b>path. </b>This will interpret rtf and html for display, but you cannot save formatting currently.</p>
78 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>path </b>- An instance of <a href="../../Collections/String.html"><span class="s2">String</span></a>.</p>
79 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
80 <p class="p6"><b><span class="Apple-tab-span"> </span>selectedString</b></p>
81 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
82 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns the text currently selected with the cursor as a String.</p>
83 <p class="p7"><br></p>
84 <p class="p6"><b><span class="Apple-tab-span"> </span>selectionStart</b></p>
85 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
86 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns the start of the current selection as an integer.</p>
87 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
88 <p class="p6"><b><span class="Apple-tab-span"> </span>selectionSize</b></p>
89 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
90 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns the size of the current selection as an integer.</p>
91 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
92 <p class="p6"><span class="s9"><span class="Apple-tab-span"> </span></span><b>usesTabToFocusNextView_(bool)</b></p>
93 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
94 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Default is true. If false, then hitting tab will write a tab in the text view, rathern than jumping to the next view.</p>
95 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bool </b>- An instance of <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a>.</p>
96 <p class="p5"><br></p>
97 <p class="p6"><span class="s9"><span class="Apple-tab-span"> </span></span><b>enterInterpretsSelection</b></p>
98 <p class="p6"><b><span class="Apple-tab-span"> </span>enterInterpretsSelection_ (bool)</b></p>
99 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
100 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Determines if a selection can be interpreted with the cmd-enter or ctrl-c . Default is true.</p>
101 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bool </b>- An instance of <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a>.</p>
102 <p class="p9"><br></p>
103 <p class="p6"><b><span class="Apple-tab-span"> </span>enabled_ (bool)</b> same as <b>editable_(bool)</b></p>
104 <p class="p6"><span class="Apple-tab-span"> </span><b>editable</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
105 <p class="p6"><b><span class="Apple-tab-span"> </span>editable_ (bool)</b></p>
106 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
107 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Without setting <b>editable, </b>it returns nil, though the content will be editable. However, you can explicitly set <b>editable</b> to true or false, and it will make the view editable or otherwise.</p>
108 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bool </b>- An instance of <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a>.</p>
109 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
110 <p class="p12"><b>Customizing Appearance and Changing Content</b></p>
111 <p class="p13"><br></p>
112 <p class="p6"><b><span class="Apple-tab-span"> </span>font</b></p>
113 <p class="p6"><b><span class="Apple-tab-span"> </span>font_ (argFont)</b></p>
114 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
115 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the <b>font</b> variable of the text view, and changes the Font of the entire text in the view. Default value is nil. If you loaded a text with <b>open</b>, then the font will still be nil. Changing the font of the content using OSX's cmd-T text formatter will not change the <b>font</b> variable. For more precise control of the font, see <b>setFont</b> below.</p>
116 <p class="p6"><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="s6">Font</span></a>.</p>
117 <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></p>
118 <p class="p6"><b><span class="Apple-tab-span"> </span>stringColor</b></p>
119 <p class="p6"><b><span class="Apple-tab-span"> </span>stringColor_ (color)</b></p>
120 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
121 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the <b>stringColor</b> variable of the text view, and changes the stringColor of the entire text in the view. Default value is nil. If you loaded a text with <b>open</b>, then the stringColor will be nil. Changing the stringColor of the content using OSX's cmd-T text formatter will not change the <b>font</b> variable. For more precise control of the string color, see <b>setStringColor</b> below.</p>
122 <p class="p8"><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>
123 <p class="p5"><br></p>
124 <p class="p6"><b><span class="Apple-tab-span"> </span>autohidesScrollers_ (bool)</b></p>
125 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
126 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Overrides <b>hasHorizontalScroller_ and hasVerticalScroller_ . </b>Default is false.</p>
127 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bool </b>- An instance of <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a>.</p>
128 <p class="p5"><br></p>
129 <p class="p6"><b><span class="Apple-tab-span"> </span>hasHorizontalScroller_ (bool)</b></p>
130 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
131 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Is overriden by <b>autohidesScrollers_. </b>Default is false.</p>
132 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bool </b>- An instance of <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a>.</p>
133 <p class="p5"><br></p>
134 <p class="p6"><b><span class="Apple-tab-span"> </span>hasVerticalScroller_ (bool)</b></p>
135 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
136 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Is overriden by <b>autohidesScrollers_.</b> Default is false.</p>
137 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bool </b>- An instance of <a href="../../Core/Boolean.html"><span class="s2">Boolean</span></a>.</p>
138 <p class="p7"><span class="Apple-tab-span"> </span></p>
139 <p class="p6"><b><span class="Apple-tab-span"> </span>setStringColor (color, rangeStart, rangeSize)</b></p>
140 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
141 <p class="p8"><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>
142 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>rangeStart </b>- The beginning of a range of text in which to change the color.</p>
143 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>rangeSize </b>- The length of a range of text in which to change the color.</p>
144 <p class="p5"><br></p>
145 <p class="p6"><b><span class="Apple-tab-span"> </span>setFont (font, rangestart, rangesize)</b></p>
146 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
147 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>font </b>- An instance of <a href="../Main-GUI/Font.html"><span class="s2">Font</span></a>.</p>
148 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>rangeStart </b>- The beginning of a range of text in which to change the font.</p>
149 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>rangeSize </b>- The length of a range of text in which to change the font.</p>
150 <p class="p5"><br></p>
151 <p class="p6"><b><span class="Apple-tab-span"> </span>setString (string, rangestart, rangesize)</b></p>
152 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
153 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>string </b>- An instance of <a href="../../Collections/String.html"><span class="s2">String</span></a>.</p>
154 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>rangeStart </b>- The beginning of a range of text in which to change the content.</p>
155 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>rangeSize </b>- The length of a range of text in which to change the content.</p>
156 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
157 <p class="p8"><span class="Apple-tab-span"> </span><b>syntaxColorize</b></p>
158 <p class="p9"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></p>
159 <p class="p8"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Runs the default syntax colorizer over the contents of the TextView.</p>
160 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
161 <p class="p12"><b>Subclassing and Internal Methods</b></p>
162 <p class="p6"><span class="s10"><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>
163 <p class="p7"><span class="Apple-tab-span"> </span></p>
164 <p class="p6"><b><span class="Apple-tab-span"> </span>mouseUp (x, y, modifiers, buttonNumber, clickCount, clickPos)</b></p>
165 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
166 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Normally not called directly. Used by the primitive.</p>
167 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
168 <p class="p6"><b><span class="Apple-tab-span"> </span>selectedString_ (str)</b></p>
169 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
170 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Normally not called directly.</p>
171 <p class="p5"><br></p>
172 <p class="p5"><br></p>
173 <p class="p12"><b>Examples</b></p>
174 <p class="p11"><br></p>
175 <p class="p10">(</p>
176 <p class="p10">w = <span class="s7">Window</span>.new(<span class="s11">"Text View Example"</span>,<span class="s7">Rect</span>(100,<span class="s7">Window</span>.screenBounds.height-400, 520,300)).front;</p>
177 <p class="p10">t = <span class="s7">TextView</span>(w.asView,<span class="s7">Rect</span>(10,10, 500,200))</p>
178 <p class="p10"><span class="Apple-tab-span"> </span>.focus(<span class="s7">true</span>);</p>
179 <p class="p10">)</p>
180 <p class="p11"><br></p>
181 <p class="p14">// Using the Window you just created, try these in succession, and test how the text view responds</p>
182 <p class="p15"><span class="s3">t.mouseUpAction_{</span>|it, x, y, modifiers, buttonNumber, clickCount, pos|<span class="s3"> [pos].postln};</span></p>
183 <p class="p10">t.hasVerticalScroller_(<span class="s7">true</span>);</p>
184 <p class="p10">t.hasHorizontalScroller_(<span class="s7">true</span>);</p>
185 <p class="p10">t.autohidesScrollers_(<span class="s7">true</span>);</p>
186 <p class="p11"><br></p>
187 <p class="p16"><span class="s3">t.open(</span>"Help/GUI/Main-GUI/Button.html"<span class="s3">); </span><span class="s12">// load an html file</span></p>
188 <p class="p11"><br></p>
189 <p class="p14">// selective editing and formatting</p>
190 <p class="p10">t.setStringColor (<span class="s7">Color</span>.red, 5, 220);</p>
191 <p class="p10">t.setFont (<span class="s7">Font</span>(<span class="s11">"Courier"</span>,12), 5, 120);</p>
192 <p class="p16"><span class="s3">t.setString (</span>"\nA replacement String\n"<span class="s3">, 12, 120);</span></p>
193 <p class="p11"><br></p>
194 <p class="p14">// compare with these methods, which change everything</p>
195 <p class="p10">t.font_(<span class="s7">Font</span>(<span class="s11">"Courier"</span>,14));</p>
196 <p class="p10">t.stringColor_(<span class="s7">Color</span>.blue);</p>
197 <p class="p11"><br></p>
198 </body>
199 </html>