author | Stefan Vogel <sv@exept.de> |
Thu, 02 May 1996 18:33:21 +0200 | |
changeset 611 | 87637cf3931b |
parent 601 | 2ec9efffff79 |
child 655 | acad3ef3a46c |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1990 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
EditTextView subclass:#EditField |
|
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
14 |
instanceVariableNames:'leaveAction enabled clickAction crAction tabAction converter |
209
7a6db7fac566
dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
15 |
leaveKeys immediateAccept acceptOnLeave acceptOnReturn |
7a6db7fac566
dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
16 |
lengthLimit entryCompletionBlock passwordCharacter |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
17 |
cursorMovementWhenUpdating enableChannel autoScrollHorizontally |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
18 |
acceptOnTab' |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
19 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
343
diff
changeset
|
20 |
DefaultSelectionForegroundColor DefaultSelectionBackgroundColor' |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
21 |
poolDictionaries:'' |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
22 |
category:'Views-Text' |
0 | 23 |
! |
24 |
||
19 | 25 |
!EditField class methodsFor:'documentation'! |
26 |
||
38 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
59 | 30 |
All Rights Reserved |
38 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
19 | 41 |
documentation |
42 |
" |
|
38 | 43 |
an editable text-field. Realized by using an EditTextView, |
44 |
and forcing its size to 1 line - disabling cursor movement |
|
45 |
in the vertical direction. |
|
121 | 46 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
47 |
Basically, an editField is an editor for a single line text, |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
48 |
and provides the usual access protocol as defined in its superClasses |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
49 |
(especially: #contents / #contents:). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
50 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
51 |
The above underlying internal mechanism can be used for fields which |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
52 |
are passive; i.e. into which text can be entered and the value (string) |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
53 |
is extracted actively by someone else. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
54 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
55 |
accepting: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
56 |
The opposite way to use editFields is to connect them to a model |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
57 |
and let the field notify changes to it. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
58 |
This notification is called ``accepting''. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
59 |
Unless accepted, the models value is not updated from the editFields contents |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
60 |
this default is the normal operation and way things should work, since most |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
61 |
uses of editFields are not interrested in every individual change |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
62 |
(i.e. getting each keyStroke when a long number is entered). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
63 |
The default behavior is to ``accept'' when either return or a cursorUp/Down |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
64 |
key is pressed in a field. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
65 |
However, the field can setup to accept/not accept on leave, on return |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
66 |
or on each individual key input. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
67 |
See the methods #acceptOnLeave: / #acceptOnReturn: / #immediateAccept. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
68 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
69 |
In addition, the set of keys which are considered ``leaveKeys'' can be |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
70 |
specified by #leaveKeys: (in case you need keys other than Return, CursorUp/Down). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
71 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
72 |
models value vs. field contents: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
73 |
Although the field internally keeps its contents as some string object, |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
74 |
the application may prefer to think of numbers, floats, yes/no values etc. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
75 |
To support this, a converter may defined, which is responsible for conversion of |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
76 |
strings to/from the models domain value. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
77 |
If present (i.e. nonNil), the converter is asked to convert a string to the models |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
78 |
domain with #readValueFrom:aString and vice versa, a value to a string by #printStringFor:. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
79 |
The PrintConverter class already provides a number of standard conversions, see the examples. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
80 |
To access a converted value directly (i.e. not via the model), use #editValue. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
81 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
82 |
grouping: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
83 |
Individual fields do not know about being included in a group. This must be arranged on the |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
84 |
outside, by placing multiple fields into an EnterFieldGroup. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
85 |
This groupObject keeps a reference to one active field, and forwards input from any other |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
86 |
field to the active one. Also have a look at the examples for this. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
87 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
88 |
input completion: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
89 |
To support input completion (i.e. filename completion, classname completion etc.), |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
90 |
a completionBlock can be defined which (if non-nil) is evaluated when the completion-key |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
91 |
is pressed and its value is taken as the new field-contents. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
92 |
The physical completion-key is the Tab key (this one cannot be defined by |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
93 |
the keyboardTranslation mechanism, since that would disable the Tab-key on regular text views. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
94 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
95 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
96 |
|
586 | 97 |
[Instance variables:] |
121 | 98 |
|
99 |
leaveAction <Block | nil> if non-nil, this is evaluated with |
|
586 | 100 |
the key (#Return, #CursorUp etc.) when |
101 |
the field is left via keyboard keys. |
|
102 |
(fieldGroups use this to decide which |
|
103 |
field has to be enabled next) |
|
121 | 104 |
|
105 |
enabled <Boolean> if false, input is ignored. |
|
106 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
107 |
clickAction <Block | nil> action performed if the field is |
586 | 108 |
clicked upon. |
109 |
(this is used by the group to |
|
110 |
set the active field to the clicked upon field) |
|
121 | 111 |
|
112 |
crAction <Block | nil> if non-nil, keyboard input of a cr are not |
|
586 | 113 |
handled specially, instead this block is evaluated |
114 |
(however, this block can perform additional checks and send |
|
115 |
a #accept then) |
|
121 | 116 |
|
117 |
tabAction <Block | nil> if non-nil, keyboard input of a tab character |
|
586 | 118 |
is not entered into the text, instead this block |
119 |
is evaluated. Also, no input completion is performed if |
|
120 |
tabAction is nonNil. |
|
121 | 121 |
|
122 |
converter <PrintConverter | nil> if non-nil, this is supposed to convert between |
|
586 | 123 |
the object and its printed representation and vice versa. |
124 |
Defaults to nil i.e. assume that strings are edited. |
|
121 | 125 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
126 |
leaveKeys <Collection> keys which are interpreted as 'leaving the field' |
122 | 127 |
|
125 | 128 |
immediateAccept <Boolean> if true, every change of the text is immediately |
586 | 129 |
forwarded to the model/acceptBlock. If false, |
130 |
the changed value is only stored in the model |
|
131 |
if the field is left or accepted. |
|
132 |
Default is false. |
|
122 | 133 |
|
134 |
acceptOnLeave <Boolean> if true, leaving the field (via cursor keys) |
|
586 | 135 |
automatically accepts the value into the model. |
136 |
Default is true. |
|
122 | 137 |
|
138 |
acceptOnReturn <Boolean> if true, leaving the field via return |
|
586 | 139 |
automatically accepts the value into the model. |
140 |
Default is true. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
141 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
142 |
acceptOnTab <Boolean> if true, the Tab key accepts and leaves the field. |
586 | 143 |
If false, Tabs are entered into the contents field like |
144 |
ordinary non-control keys. |
|
145 |
AcceptOnTab is ignored if the entryCompletion block is nonNil. |
|
146 |
Default is true. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
147 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
148 |
lengthLimit <Number> the max. number of allowed characters |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
149 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
150 |
entryCompletionBlock <BlockOrNil> if non-nil, this is evaluated to complete the entry |
586 | 151 |
when Tab is pressed. |
152 |
Entry completion is used with Filenamefields or in the |
|
153 |
browser for classname/selector completion. |
|
154 |
Setting a nonNil entryCompletion disables acceptOnTab. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
155 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
156 |
passwordCharacter <CharacterOrNil> if non-nil, typed input is replaced by this character |
586 | 157 |
for display. Used for secret-input fields (such as password entry). |
158 |
Default is nil. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
159 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
160 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
161 |
cursorMovementWhenUpdating <Symbol> defines where the cursor is to be positioned if the |
586 | 162 |
model changes its value by some outside activity |
163 |
(i.e. not by user input into the field). |
|
164 |
Can be one of: |
|
165 |
#keep / nil -> stay where it was |
|
166 |
#endOfLine -> position cursor after the string |
|
167 |
#beginOfLine -> position cursor to the beginning |
|
168 |
The default is nil (i.e. stay where it was before). |
|
169 |
||
170 |
[author:] |
|
171 |
Claus Gittinger |
|
172 |
||
173 |
[see also:] |
|
174 |
DialogBox |
|
594 | 175 |
EnterFieldGroup |
176 |
EnterBox EnterBox2 |
|
177 |
FilenameEditField EditTextView |
|
19 | 178 |
" |
120 | 179 |
! |
180 |
||
181 |
examples |
|
182 |
" |
|
122 | 183 |
see more examples in EnterFieldGroup>>examples. |
184 |
||
185 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
186 |
Step-by-step introduction: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
187 |
|
120 | 188 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
189 |
basic field in some view: |
594 | 190 |
[exBegin] |
333 | 191 |
|top field| |
120 | 192 |
|
333 | 193 |
top := StandardSystemView new. |
194 |
top extent:200@100. |
|
120 | 195 |
|
333 | 196 |
field := EditField origin:0.0@0.0 in:top. |
197 |
field width:1.0. 'let its height as-is'. |
|
120 | 198 |
|
333 | 199 |
top open |
594 | 200 |
[exEnd] |
120 | 201 |
|
122 | 202 |
|
125 | 203 |
forward input in topView to the field: |
204 |
(currently, the field does not know this - therefore, |
|
205 |
its been told here ... this may change) |
|
594 | 206 |
[exBegin] |
333 | 207 |
|top field| |
122 | 208 |
|
333 | 209 |
top := StandardSystemView new. |
210 |
top extent:200@100. |
|
122 | 211 |
|
333 | 212 |
field := EditField origin:0.0@0.0 in:top. |
213 |
field width:1.0. 'let its height as-is'. |
|
122 | 214 |
|
333 | 215 |
top delegate:(KeyboardForwarder toView:field). |
216 |
field hasKeyboardFocus:true. |
|
217 |
top open |
|
594 | 218 |
[exEnd] |
122 | 219 |
|
220 |
||
125 | 221 |
to make it look better: set some inset: |
594 | 222 |
[exBegin] |
333 | 223 |
|top field spacing| |
120 | 224 |
|
333 | 225 |
top := StandardSystemView new. |
226 |
top extent:200@100. |
|
120 | 227 |
|
333 | 228 |
spacing := View viewSpacing. |
229 |
field := EditField origin:(0.0 @ spacing) in:top. |
|
230 |
field width:1.0. 'let its height as-is'. |
|
231 |
field leftInset:spacing; rightInset:spacing. |
|
120 | 232 |
|
333 | 233 |
top open |
594 | 234 |
[exEnd] |
120 | 235 |
|
122 | 236 |
|
120 | 237 |
give it an initial contents: |
594 | 238 |
[exBegin] |
333 | 239 |
|top field| |
120 | 240 |
|
333 | 241 |
top := StandardSystemView new. |
242 |
top extent:200@100. |
|
120 | 243 |
|
594 | 244 |
field := EditField origin:(0.0 @ 0.0) in:top. |
333 | 245 |
field width:1.0. |
120 | 246 |
|
333 | 247 |
field editValue:'hello world'. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
248 |
|
333 | 249 |
top open |
594 | 250 |
[exEnd] |
120 | 251 |
|
122 | 252 |
|
125 | 253 |
have it preselected: |
594 | 254 |
[exBegin] |
333 | 255 |
|top field| |
120 | 256 |
|
333 | 257 |
top := StandardSystemView new. |
258 |
top extent:200@100. |
|
120 | 259 |
|
333 | 260 |
field := EditField origin:(0.0 @ 0.0) in:top. |
261 |
field width:1.0. |
|
262 |
field editValue:'hello world' selected:true. |
|
120 | 263 |
|
333 | 264 |
top open |
594 | 265 |
[exEnd] |
120 | 266 |
|
122 | 267 |
|
120 | 268 |
have part of it preselected: |
594 | 269 |
[exBegin] |
333 | 270 |
|top field| |
120 | 271 |
|
333 | 272 |
top := StandardSystemView new. |
273 |
top extent:200@100. |
|
120 | 274 |
|
333 | 275 |
field := EditField origin:(0.0 @ 0.0) in:top. |
276 |
field width:1.0. |
|
120 | 277 |
|
333 | 278 |
field editValue:'hello world'. |
279 |
field selectFromCharacterPosition:1 to:5. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
280 |
|
333 | 281 |
top open |
594 | 282 |
[exEnd] |
120 | 283 |
|
122 | 284 |
|
125 | 285 |
set a size limit: |
594 | 286 |
[exBegin] |
333 | 287 |
|top field| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
288 |
|
333 | 289 |
top := StandardSystemView new. |
290 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
291 |
|
333 | 292 |
field := EditField origin:(0.0 @ 0.0) in:top. |
293 |
field width:1.0. |
|
294 |
field editValue:'hello'. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
295 |
|
333 | 296 |
field maxChars:8. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
297 |
|
333 | 298 |
top open |
594 | 299 |
[exEnd] |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
300 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
301 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
302 |
set a size limit, initial width and stop it from scrolling |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
303 |
notice: you may prefer a constant-pitch font (such as courier): |
594 | 304 |
[exBegin] |
333 | 305 |
|top field| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
306 |
|
333 | 307 |
top := StandardSystemView new. |
308 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
309 |
|
333 | 310 |
field := EditField origin:(0.0 @ 0.0) in:top. |
311 |
field innerWidth:(field font widthOf:'00000000'). |
|
312 |
field editValue:'12345678'. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
313 |
|
333 | 314 |
field maxChars:8. |
315 |
field autoScroll:false. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
316 |
|
333 | 317 |
top open |
594 | 318 |
[exEnd] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
319 |
|
125 | 320 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
321 |
enable / disable: |
594 | 322 |
[exBegin] |
333 | 323 |
|top panel check field ena| |
324 |
||
325 |
top := StandardSystemView new. |
|
326 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
327 |
|
333 | 328 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
329 |
panel borderWidth:0. |
|
330 |
panel horizontalLayout:#left. |
|
331 |
panel horizontalInset:View viewSpacing. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
332 |
|
333 | 333 |
check := CheckBox label:'enable' in:panel. |
334 |
check turnOn. |
|
335 |
check action:[:onOff | onOff ifTrue:[field enable] ifFalse:[field disable]]. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
336 |
|
333 | 337 |
panel add:(View new height:30; borderWidth:0). |
125 | 338 |
|
333 | 339 |
field := EditField in:panel. |
340 |
field width:1.0. |
|
341 |
field editValue:'hello'. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
342 |
|
333 | 343 |
top open |
594 | 344 |
[exEnd] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
345 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
346 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
347 |
enable / disable using a channel: |
594 | 348 |
[exBegin] |
333 | 349 |
|top panel check field ena| |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
350 |
|
333 | 351 |
top := StandardSystemView new. |
352 |
top extent:200@100. |
|
125 | 353 |
|
333 | 354 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
355 |
panel borderWidth:0. |
|
356 |
panel horizontalLayout:#left. |
|
357 |
panel horizontalInset:View viewSpacing. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
358 |
|
333 | 359 |
ena := true asValue. |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
360 |
|
333 | 361 |
check := CheckBox label:'enable' in:panel. |
362 |
check model:ena. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
363 |
|
333 | 364 |
panel add:(View new height:30; borderWidth:0). |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
365 |
|
333 | 366 |
field := EditField in:panel. |
367 |
field enableChannel:ena. |
|
368 |
field width:1.0. |
|
369 |
field editValue:'hello'. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
370 |
|
333 | 371 |
top open |
594 | 372 |
[exEnd] |
125 | 373 |
|
374 |
||
121 | 375 |
use a converter: |
125 | 376 |
- numbers (default to 0): |
594 | 377 |
[exBegin] |
378 |
|top field spacing| |
|
121 | 379 |
|
333 | 380 |
top := StandardSystemView new. |
381 |
top extent:200@100. |
|
121 | 382 |
|
594 | 383 |
spacing := View viewSpacing. |
384 |
||
385 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 386 |
field width:1.0. |
594 | 387 |
field horizontalInset:spacing. |
121 | 388 |
|
333 | 389 |
field converter:(PrintConverter new initForNumber). |
390 |
field editValue:1234. |
|
391 |
field acceptAction:[:value | Transcript showCr:value]. |
|
392 |
field crAction:[field accept. top destroy]. |
|
393 |
top open. |
|
594 | 394 |
[exEnd] |
121 | 395 |
|
396 |
- dates: |
|
594 | 397 |
[exBegin] |
398 |
|top field spacing| |
|
121 | 399 |
|
333 | 400 |
top := StandardSystemView new. |
401 |
top extent:200@100. |
|
121 | 402 |
|
594 | 403 |
spacing := View viewSpacing. |
404 |
||
405 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 406 |
field width:1.0. |
594 | 407 |
field horizontalInset:spacing. |
121 | 408 |
|
333 | 409 |
field converter:(PrintConverter new initForDate). |
410 |
field editValue:Date today. |
|
411 |
field acceptAction:[:value | Transcript showCr:value class name , ' ' , value printString]. |
|
412 |
field crAction:[field accept. top destroy]. |
|
413 |
top open. |
|
594 | 414 |
[exEnd] |
121 | 415 |
|
122 | 416 |
|
125 | 417 |
setting immediateAccept, makes the field update with every key: |
418 |
||
419 |
- immediate accept numbers, defaulting to nil: |
|
594 | 420 |
[exBegin] |
421 |
|top field spacing| |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
422 |
|
333 | 423 |
top := StandardSystemView new. |
424 |
top extent:200@100. |
|
121 | 425 |
|
594 | 426 |
spacing := View viewSpacing. |
427 |
||
428 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 429 |
field width:1.0. |
594 | 430 |
field horizontalInset:spacing. |
121 | 431 |
|
333 | 432 |
field converter:(PrintConverter new initForNumberOrNil). |
433 |
field immediateAccept:true. |
|
434 |
field editValue:1234. |
|
435 |
field acceptAction:[:value | Transcript showCr:value]. |
|
436 |
field crAction:[field accept. top destroy]. |
|
437 |
top open. |
|
594 | 438 |
[exEnd] |
121 | 439 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
440 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
441 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
442 |
grouping multiple fields, and forward keyPres from the outer view to the active field |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
443 |
(i.e. actually: to the group): |
594 | 444 |
[exBegin] |
333 | 445 |
|top field1 field2 field3 group| |
121 | 446 |
|
122 | 447 |
|
333 | 448 |
top := StandardSystemView new. |
449 |
top extent:200@100. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
450 |
|
333 | 451 |
field1 := EditField origin:(0.0 @ 0.0) in:top. |
452 |
field1 width:1.0. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
453 |
|
333 | 454 |
field2 := EditField origin:(0.0 @ 0.0) in:top. |
455 |
field2 width:0.5. |
|
456 |
field2 topInset:(field1 height); bottomInset:(field1 height negated). |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
457 |
|
333 | 458 |
field3 := EditField origin:(0.5 @ 0.0) in:top. |
459 |
field3 width:0.5. |
|
460 |
field3 topInset:(field1 height); bottomInset:(field1 height negated). |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
461 |
|
333 | 462 |
group := EnterFieldGroup new. |
463 |
group add:field1; add:field2; add:field3. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
464 |
|
333 | 465 |
top delegate:(KeyboardForwarder to:group). |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
466 |
|
333 | 467 |
top open. |
594 | 468 |
[exEnd] |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
469 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
470 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
471 |
in addition: tell the group to close when the last field is left: |
594 | 472 |
[exBegin] |
333 | 473 |
|top field1 field2 field3 group| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
474 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
475 |
|
333 | 476 |
top := StandardSystemView new. |
477 |
top extent:200@100. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
478 |
|
333 | 479 |
field1 := EditField origin:(0.0 @ 0.0) in:top. |
480 |
field1 width:1.0. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
481 |
|
333 | 482 |
field2 := EditField origin:(0.0 @ 0.0) in:top. |
483 |
field2 width:0.5. |
|
484 |
field2 topInset:(field1 height); bottomInset:(field1 height negated). |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
485 |
|
333 | 486 |
field3 := EditField origin:(0.5 @ 0.0) in:top. |
487 |
field3 width:0.5. |
|
488 |
field3 topInset:(field1 height); bottomInset:(field1 height negated). |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
489 |
|
333 | 490 |
group := EnterFieldGroup new. |
491 |
group add:field1; add:field2; add:field3. |
|
492 |
group leaveAction:[top destroy]. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
493 |
|
333 | 494 |
top delegate:(KeyboardForwarder to:group). |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
495 |
|
333 | 496 |
top open. |
594 | 497 |
[exEnd] |
127 | 498 |
|
499 |
||
120 | 500 |
use a model: |
501 |
(see changing model value in inspector when return is pressed in the field) |
|
594 | 502 |
[exBegin] |
333 | 503 |
|top field model| |
120 | 504 |
|
333 | 505 |
model := 'hello world' asValue. |
120 | 506 |
|
333 | 507 |
top := StandardSystemView new. |
508 |
top extent:200@100. |
|
120 | 509 |
|
333 | 510 |
field := EditField origin:(0.0 @ 0.0) in:top. |
511 |
field width:1.0. |
|
512 |
field model:model. |
|
513 |
field acceptOnReturn:true. |
|
120 | 514 |
|
333 | 515 |
top open. |
516 |
model inspect. |
|
594 | 517 |
[exEnd] |
121 | 518 |
|
122 | 519 |
|
127 | 520 |
two views on the same model (each accepts on return): |
594 | 521 |
[exBegin] |
333 | 522 |
|top1 top2 field1 field2 model| |
121 | 523 |
|
333 | 524 |
model := 'hello world' asValue. |
121 | 525 |
|
333 | 526 |
top1 := StandardSystemView new. |
527 |
top1 extent:200@100. |
|
528 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
529 |
field1 width:1.0. |
|
530 |
field1 model:model. |
|
531 |
field1 acceptOnReturn:true. |
|
532 |
top1 open. |
|
121 | 533 |
|
333 | 534 |
top2 := StandardSystemView new. |
535 |
top2 extent:200@100. |
|
536 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
537 |
field2 width:1.0. |
|
538 |
field2 model:model. |
|
539 |
field2 acceptOnReturn:true. |
|
540 |
top2 open. |
|
594 | 541 |
[exEnd] |
121 | 542 |
|
127 | 543 |
two views on the same model (no accept on return): |
594 | 544 |
[exBegin] |
333 | 545 |
|top1 top2 field1 field2 model| |
127 | 546 |
|
333 | 547 |
model := 'hello world' asValue. |
127 | 548 |
|
333 | 549 |
top1 := StandardSystemView new. |
550 |
top1 extent:200@100. |
|
551 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
552 |
field1 width:1.0. |
|
553 |
field1 model:model; acceptOnReturn:false. |
|
554 |
top1 open. |
|
127 | 555 |
|
333 | 556 |
top2 := StandardSystemView new. |
557 |
top2 extent:200@100. |
|
558 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
559 |
field2 width:1.0. |
|
560 |
field2 model:model; acceptOnReturn:false. |
|
561 |
top2 open. |
|
594 | 562 |
[exEnd] |
127 | 563 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
564 |
with immediate accept (every key updates the model): |
594 | 565 |
[exBegin] |
333 | 566 |
|top1 top2 field1 field2 model| |
125 | 567 |
|
333 | 568 |
model := 'hello world' asValue. |
125 | 569 |
|
333 | 570 |
top1 := StandardSystemView new. |
571 |
top1 extent:200@100. |
|
572 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
573 |
field1 width:1.0. |
|
574 |
field1 model:model; immediateAccept:true. |
|
575 |
top1 open. |
|
125 | 576 |
|
333 | 577 |
top2 := StandardSystemView new. |
578 |
top2 extent:200@100. |
|
579 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
580 |
field2 width:1.0. |
|
581 |
field2 model:model; immediateAccept:true. |
|
582 |
top2 open. |
|
594 | 583 |
[exEnd] |
122 | 584 |
|
121 | 585 |
just an example; a checkBox and an editField on the same model: |
594 | 586 |
[exBegin] |
333 | 587 |
|top1 top2 field1 box model| |
121 | 588 |
|
333 | 589 |
model := false asValue. |
121 | 590 |
|
333 | 591 |
top1 := StandardSystemView new. |
592 |
top1 extent:200@100. |
|
593 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
594 |
field1 width:1.0. |
|
595 |
field1 converter:(PrintConverter new initForYesNo). |
|
596 |
field1 model:model. |
|
597 |
top1 open. |
|
121 | 598 |
|
333 | 599 |
top2 := StandardSystemView new. |
600 |
top2 extent:200@100. |
|
601 |
box := CheckBox on:model. |
|
602 |
box label:'on/off'. |
|
603 |
top2 add:box. |
|
604 |
top2 open. |
|
121 | 605 |
|
333 | 606 |
model inspect. |
594 | 607 |
[exEnd] |
125 | 608 |
|
609 |
||
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
610 |
multiple editFields on multiple models (value holders): |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
611 |
(the fields are connected by a group to allow tabbing) |
594 | 612 |
[exBegin] |
613 |
|top panel group field1 field2 field3 box |
|
614 |
v1 v2 v3 spacing| |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
615 |
|
333 | 616 |
v1 := true asValue. |
617 |
v2 := 'some string' asValue. |
|
618 |
v3 := 1.2 asValue. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
619 |
|
333 | 620 |
top := StandardSystemView new. |
621 |
top extent:200@100. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
622 |
|
333 | 623 |
panel := VerticalPanelView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
624 |
|
594 | 625 |
spacing := View viewSpacing. |
626 |
||
333 | 627 |
field1 := EditField new. |
628 |
field1 width:1.0. |
|
594 | 629 |
field1 horizontalInset:spacing. |
333 | 630 |
field1 converter:(PrintConverter new initForYesNo). |
631 |
field1 model:v1. |
|
632 |
panel add:field1. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
633 |
|
333 | 634 |
field2 := EditField new. |
635 |
field2 width:1.0. |
|
594 | 636 |
field2 horizontalInset:spacing. |
333 | 637 |
field2 model:v2. |
638 |
panel add:field2. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
639 |
|
333 | 640 |
field3 := EditField new. |
641 |
field3 width:1.0. |
|
594 | 642 |
field3 horizontalInset:spacing. |
333 | 643 |
field3 converter:(PrintConverter new initForNumber). |
644 |
field3 model:v3. |
|
645 |
panel add:field3. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
646 |
|
333 | 647 |
group := EnterFieldGroup new. |
648 |
group add:field1; add:field2; add:field3. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
649 |
|
333 | 650 |
top openModal. |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
651 |
|
333 | 652 |
Transcript showCr:v1 value. |
653 |
Transcript showCr:v2 value. |
|
654 |
Transcript showCr:v3 value. |
|
594 | 655 |
[exEnd] |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
656 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
657 |
|
125 | 658 |
connecting fields: |
659 |
update field2 wehenever field1 is changed. |
|
660 |
(normally, the processing below (xChanged) is done in your application |
|
661 |
class, or in a complex model. For the demonstration below, we use |
|
662 |
a Plug to simulate the protocol.) |
|
594 | 663 |
[exBegin] |
333 | 664 |
|application top field1 field2 value1 value2| |
125 | 665 |
|
333 | 666 |
application := Plug new. |
667 |
application respondTo:#value1Changed |
|
668 |
with:[value2 value:(value1 value isNil ifTrue:[nil] |
|
669 |
ifFalse:[value1 value squared])]. |
|
125 | 670 |
|
333 | 671 |
value1 := 1 asValue. |
672 |
value2 := 1 asValue. |
|
125 | 673 |
|
333 | 674 |
top := Dialog new. |
675 |
top extent:200@200. |
|
125 | 676 |
|
333 | 677 |
(top addTextLabel:'some number:') layout:#left. |
678 |
top addVerticalSpace. |
|
125 | 679 |
|
333 | 680 |
(top addInputFieldOn:value1 tabable:false) |
681 |
converter:(PrintConverter new initForNumberOrNil); |
|
682 |
immediateAccept:true. |
|
683 |
top addVerticalSpace. |
|
125 | 684 |
|
333 | 685 |
(top addTextLabel:'squared:') layout:#left. |
686 |
top addVerticalSpace. |
|
687 |
(top addInputFieldOn:value2 tabable:false) |
|
688 |
converter:(PrintConverter new initForNumberOrNil). |
|
125 | 689 |
|
333 | 690 |
value1 onChangeSend:#value1Changed to:application. |
125 | 691 |
|
333 | 692 |
top openModeless. |
594 | 693 |
[exEnd] |
125 | 694 |
|
695 |
||
696 |
two-way connect: |
|
697 |
each field updates the other (notice, that we have to turn off |
|
698 |
onChange: notification, to avoid an endless notification cycle) |
|
594 | 699 |
[exBegin] |
333 | 700 |
|application top field1 field2 value1 value2| |
125 | 701 |
|
333 | 702 |
application := Plug new. |
703 |
application respondTo:#value1Changed |
|
704 |
with:[value2 retractInterestsFor:application. |
|
705 |
value2 value:(value1 value isNil ifTrue:[nil] |
|
706 |
ifFalse:[value1 value squared]). |
|
707 |
value2 onChangeSend:#value2Changed to:application. |
|
708 |
]. |
|
709 |
application respondTo:#value2Changed |
|
710 |
with:[value1 retractInterestsFor:application. |
|
711 |
value1 value:(value2 value isNil ifTrue:[nil] |
|
712 |
ifFalse:[value2 value sqrt]). |
|
713 |
value1 onChangeSend:#value1Changed to:application. |
|
714 |
]. |
|
125 | 715 |
|
333 | 716 |
value1 := 1 asValue. |
717 |
value2 := 1 asValue. |
|
125 | 718 |
|
333 | 719 |
top := Dialog new. |
720 |
top extent:200@200. |
|
125 | 721 |
|
333 | 722 |
(top addTextLabel:'some number:') layout:#left. |
723 |
top addVerticalSpace. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
724 |
|
333 | 725 |
(top addInputFieldOn:value1 tabable:false) |
726 |
converter:(PrintConverter new initForNumberOrNil); |
|
727 |
immediateAccept:true. |
|
728 |
top addVerticalSpace. |
|
125 | 729 |
|
333 | 730 |
(top addTextLabel:'squared:') layout:#left. |
731 |
top addVerticalSpace. |
|
732 |
(top addInputFieldOn:value2 tabable:false) |
|
733 |
converter:(PrintConverter new initForNumberOrNil); |
|
734 |
immediateAccept:true. |
|
125 | 735 |
|
333 | 736 |
value1 onChangeSend:#value1Changed to:application. |
737 |
value2 onChangeSend:#value2Changed to:application. |
|
125 | 738 |
|
333 | 739 |
top openModeless. |
594 | 740 |
[exEnd] |
120 | 741 |
" |
19 | 742 |
! ! |
0 | 743 |
|
744 |
!EditField class methodsFor:'defaults'! |
|
745 |
||
125 | 746 |
defaultLeaveKeys |
128 | 747 |
"return the set of keys which are taken as leave-keys. |
748 |
If the field is in an enterFieldGroup, all leave keys will be |
|
749 |
forwarded to the group and possible step to the next/previous field. |
|
750 |
Also, if acceptOnLeave is true, leave keys will store the current |
|
751 |
value into their model (if any)" |
|
752 |
||
125 | 753 |
^ #(Return CursorUp CursorDown Next Previous Accept) |
754 |
! |
|
755 |
||
192 | 756 |
defaultNumberOfLines |
757 |
"the number of lines in the field" |
|
758 |
||
759 |
^ 1 |
|
760 |
! |
|
761 |
||
59 | 762 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
763 |
"extract values from the styleSheet and cache them in class variables" |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
764 |
|
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
765 |
<resource: #style (#editFieldForegroundColor #editFieldBackgroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
766 |
#editFieldSelectionForegroundColor #editFieldSelectionBackgroundColor |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
767 |
#editFieldFont)> |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
768 |
|
60 | 769 |
DefaultForegroundColor := StyleSheet colorAt:'editFieldForegroundColor' default:Black. |
770 |
DefaultBackgroundColor := StyleSheet colorAt:'editFieldBackgroundColor' default:White. |
|
771 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'editFieldSelectionForegroundColor' default:DefaultBackgroundColor. |
|
772 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'editFieldSelectionBackgroundColor' default:DefaultForegroundColor. |
|
773 |
DefaultFont := StyleSheet fontAt:'editFieldFont' default:nil. |
|
59 | 774 |
|
775 |
" |
|
60 | 776 |
self updateStyleCache |
59 | 777 |
" |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
778 |
|
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
779 |
"Modified: 1.3.1996 / 13:45:43 / cg" |
0 | 780 |
! ! |
781 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
782 |
!EditField methodsFor:'accepting'! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
783 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
784 |
accept |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
785 |
"" |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
786 |
|val string| |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
787 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
788 |
super accept. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
789 |
converter notNil ifTrue:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
790 |
val := self editValue. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
791 |
string := converter printStringFor:val. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
792 |
string ~= self contents ifTrue:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
793 |
self contents:string. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
794 |
self flash |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
795 |
] |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
796 |
]. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
797 |
! ! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
798 |
|
192 | 799 |
!EditField methodsFor:'accessing-behavior'! |
125 | 800 |
|
192 | 801 |
acceptOnLeave:aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
802 |
"set/clear the acceptOnLeave flag. The default is false. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
803 |
If true, leaving the box (via return, cursor etc) accepts my |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
804 |
string into the valueHolder (if any). |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
805 |
(actually, the set of keys can be specified with #leaveKeys:)" |
125 | 806 |
|
192 | 807 |
acceptOnLeave := aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
808 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
809 |
"Modified: 16.12.1995 / 16:26:45 / cg" |
192 | 810 |
! |
811 |
||
812 |
acceptOnReturn:aBoolean |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
813 |
"set/clear the acceptOnReturn flag. The default is false. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
814 |
If true, leaving the box via return accepts my |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
815 |
string into the valueHolder (if any)." |
192 | 816 |
|
817 |
acceptOnReturn := aBoolean |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
818 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
819 |
"Modified: 16.12.1995 / 16:25:34 / cg" |
125 | 820 |
! |
821 |
||
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
822 |
acceptOnTab:aBoolean |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
823 |
"set/clear the acceptOnTab flag. The default is true. |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
824 |
If true, a pressed Tab key accepts and leaves the box. |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
825 |
If false, the Tab key is treated like any normal input character |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
826 |
(i.e. inserted into the contents)." |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
827 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
828 |
acceptOnTab := aBoolean |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
829 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
830 |
"Created: 24.1.1996 / 13:13:37 / cg" |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
831 |
! |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
832 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
833 |
autoScroll:aBoolean |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
834 |
"turn on/off automatic scrolling upon keyboard entry |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
835 |
to make the cursor visible." |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
836 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
837 |
autoScrollHorizontally := aBoolean |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
838 |
! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
839 |
|
325 | 840 |
clickAction:aBlock |
841 |
"define an action to be evaluated when being clicked upon" |
|
842 |
||
843 |
clickAction := aBlock |
|
844 |
! |
|
845 |
||
192 | 846 |
crAction:aBlock |
847 |
"define an action to be evaluated when the return key is pressed." |
|
848 |
||
849 |
crAction := aBlock |
|
850 |
! |
|
125 | 851 |
|
192 | 852 |
cursorMovementWhenUpdating:aSymbol |
853 |
"define what should be done with the cursor, when I update |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
854 |
my contents from the model. Allowed arguments are: |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
855 |
#keep / nil -> stay where it was |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
856 |
#endOfLine -> position cursor after the string |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
857 |
#beginOfLine -> position cursor to the beginning |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
858 |
The default is #endOfLine. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
859 |
This may be useful for fields which get new values assigned from |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
860 |
the program (i.e. not from the user)" |
125 | 861 |
|
192 | 862 |
cursorMovementWhenUpdating := aSymbol |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
863 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
864 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
192 | 865 |
! |
866 |
||
867 |
disable |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
868 |
"disable the field; hide the cursor and ignore input" |
192 | 869 |
|
870 |
enabled ifTrue:[ |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
871 |
enabled := false. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
872 |
self hideCursor |
125 | 873 |
] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
874 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
875 |
"Modified: 16.12.1995 / 16:28:05 / cg" |
125 | 876 |
! |
877 |
||
192 | 878 |
enable |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
879 |
"enable the field; show the cursor and allow input" |
127 | 880 |
|
192 | 881 |
enabled ifFalse:[ |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
882 |
enabled := true. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
883 |
super showCursor |
192 | 884 |
] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
885 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
886 |
"Modified: 16.12.1995 / 16:28:09 / cg" |
127 | 887 |
! |
888 |
||
192 | 889 |
entryCompletionBlock:aOneArgBlock |
890 |
"define an action to be evaluated when Tab (NameCompletion) is pressed. |
|
891 |
The block gets the current contents as argument." |
|
892 |
||
893 |
entryCompletionBlock := aOneArgBlock |
|
125 | 894 |
! |
895 |
||
192 | 896 |
immediateAccept:aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
897 |
"set/clear the immediateAccept flag. The default is false. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
898 |
If true, every pressed key immediately accepts my |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
899 |
string into the valueHolder (if any)." |
155 | 900 |
|
192 | 901 |
immediateAccept := aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
902 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
903 |
"Modified: 16.12.1995 / 16:25:57 / cg" |
192 | 904 |
! |
155 | 905 |
|
192 | 906 |
leaveAction:aBlock |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
907 |
"define an action to be evaluated when field is left by return or cursor keys. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
908 |
(actually, the set of keys can be specified with #leaveKeys:)" |
192 | 909 |
|
910 |
leaveAction := aBlock |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
911 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
912 |
"Modified: 16.12.1995 / 16:26:36 / cg" |
155 | 913 |
! |
914 |
||
192 | 915 |
leaveKeys:aCollectionOfKeySymbols |
916 |
"define the set of keys which are interpreted as leaveKeys. |
|
917 |
I.e. those that make the field inactive and accept (if acceptOnLeave is true). |
|
918 |
The default is a set of #CursorUp, #CursorDown, #Next, #Prior and #Return." |
|
155 | 919 |
|
192 | 920 |
leaveKeys := aCollectionOfKeySymbols |
921 |
! |
|
155 | 922 |
|
594 | 923 |
makeTabable |
924 |
"arrange for Tab to accept & leave the field |
|
925 |
If the field is part of a group, the next field gets the |
|
926 |
input focus" |
|
927 |
||
928 |
leaveKeys isNil ifTrue:[ |
|
929 |
leaveKeys := self class defaultLeaveKeys |
|
930 |
]. |
|
931 |
leaveKeys := leaveKeys copyWith:#Tab |
|
932 |
||
933 |
"Created: 27.4.1996 / 17:09:48 / cg" |
|
934 |
! |
|
935 |
||
192 | 936 |
tabAction:aBlock |
937 |
"define an action to be evaluated when the tabulator key is pressed." |
|
155 | 938 |
|
192 | 939 |
tabAction := aBlock |
594 | 940 |
! |
941 |
||
942 |
tabKey:aKeySymbol |
|
943 |
"arrange for aKeySymbol to accept & leave the field |
|
944 |
If the field is part of a group, the next field gets the |
|
945 |
input focus" |
|
946 |
||
947 |
leaveKeys isNil ifTrue:[ |
|
948 |
leaveKeys := self class defaultLeaveKeys |
|
949 |
]. |
|
950 |
leaveKeys := leaveKeys copyWith:#Tab |
|
951 |
||
952 |
"Created: 27.4.1996 / 17:08:54 / cg" |
|
187 | 953 |
! ! |
125 | 954 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
955 |
!EditField methodsFor:'accessing-channels'! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
956 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
957 |
enableChannel |
601 | 958 |
"return a valueHolder for enable/disable" |
959 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
960 |
^ enableChannel |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
961 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
962 |
"Modified: 6.9.1995 / 13:43:33 / claus" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
963 |
"Created: 16.12.1995 / 16:29:05 / cg" |
601 | 964 |
"Modified: 30.4.1996 / 15:09:09 / cg" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
965 |
! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
966 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
967 |
enableChannel:aValueHolder |
601 | 968 |
"set the valueHolder, which holds the enable boolean value" |
969 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
970 |
|wasEnabled| |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
971 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
972 |
enableChannel notNil ifTrue:[ |
601 | 973 |
wasEnabled := enableChannel value. |
974 |
enableChannel retractInterestsFor:self. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
975 |
] ifFalse:[ |
601 | 976 |
wasEnabled := enabled |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
977 |
]. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
978 |
enableChannel := aValueHolder. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
979 |
aValueHolder onChangeSend:#enableStateChange to:self. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
980 |
enableChannel value ~~ wasEnabled ifTrue:[ |
601 | 981 |
self enableStateChange |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
982 |
] |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
983 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
984 |
"Created: 16.12.1995 / 16:35:32 / cg" |
601 | 985 |
"Modified: 30.4.1996 / 15:10:03 / cg" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
986 |
! ! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
987 |
|
187 | 988 |
!EditField methodsFor:'accessing-contents'! |
125 | 989 |
|
187 | 990 |
contents |
991 |
"return contents as a string |
|
992 |
- redefined since EditFields hold only one line of text. |
|
993 |
In your application, please use #editValue; |
|
994 |
it uses a converter (if any) and is compatible to ST-80." |
|
995 |
||
996 |
list isNil ifTrue:[^ '']. |
|
997 |
(list size == 0) ifTrue:[^ '']. |
|
998 |
^ list at:1 |
|
999 |
! |
|
1000 |
||
125 | 1001 |
contents:someText |
1002 |
"set the contents from a string |
|
1003 |
- redefined to place the cursor to the end. |
|
1004 |
In your application, please use #editValue:; |
|
1005 |
it uses a converter (if any) and is compatible to ST-80." |
|
1006 |
||
187 | 1007 |
|newCol| |
1008 |
||
1009 |
newCol := cursorCol. |
|
1010 |
||
125 | 1011 |
super contents:someText. |
1012 |
||
187 | 1013 |
cursorMovementWhenUpdating == #endOfLine ifTrue:[ |
1014 |
newCol := (someText size + 1). |
|
1015 |
] ifFalse:[ |
|
1016 |
cursorMovementWhenUpdating == #beginOfLine ifTrue:[ |
|
1017 |
newCol := 1 |
|
1018 |
] ifFalse:[ |
|
1019 |
"/ default: stay where it was |
|
1020 |
] |
|
1021 |
]. |
|
125 | 1022 |
|
187 | 1023 |
self cursorCol:newCol. |
125 | 1024 |
! |
1025 |
||
192 | 1026 |
converter |
1027 |
"return the converter (if any)." |
|
1028 |
||
1029 |
^ converter |
|
1030 |
! |
|
1031 |
||
1032 |
converter:aConverter |
|
1033 |
"set the converter. If non-nil, |
|
1034 |
the converter is applied to the text to convert from the string |
|
1035 |
representation to the actual object value and vice versa. |
|
1036 |
The default converter is nil, meaning no-conversion |
|
1037 |
(i.e. the edited object is the string itself." |
|
1038 |
||
1039 |
converter := aConverter |
|
1040 |
! |
|
1041 |
||
125 | 1042 |
editValue |
1043 |
"if the field edits a string, this is a name alias for #contents. |
|
1044 |
Otherwise, if there is a converter, return the edited string |
|
1045 |
converted to an appropriate object." |
|
1046 |
||
1047 |
|string| |
|
1048 |
||
1049 |
string := self contents. |
|
279 | 1050 |
string isNil ifTrue:[string := '']. |
125 | 1051 |
converter isNil ifTrue:[^ string]. |
1052 |
^ converter readValueFrom:string |
|
1053 |
! |
|
0 | 1054 |
|
125 | 1055 |
editValue:aStringOrObject |
1056 |
"set the contents. If there is a converter, use it to convert |
|
1057 |
the object into a printed representation. |
|
1058 |
Otherwise, the argument is supposed to be a string like object, |
|
1059 |
and used directly (i.e. this is equivalent to sending #contents:)." |
|
1060 |
||
1061 |
self editValue:aStringOrObject selected:false |
|
0 | 1062 |
! |
1063 |
||
125 | 1064 |
editValue:aStringOrObject selected:aBoolean |
1065 |
"set the contents. If there is a converter, use it to convert |
|
1066 |
the object into a printed representation. |
|
1067 |
Otherwise, the argument is supposed to be a string like object, |
|
187 | 1068 |
and used directly (i.e. this is equivalent to sending #initialText:selected:)." |
125 | 1069 |
|
1070 |
|string| |
|
1071 |
||
1072 |
converter notNil ifTrue:[ |
|
1073 |
string := converter printStringFor:aStringOrObject |
|
1074 |
] ifFalse:[ |
|
1075 |
string := aStringOrObject. |
|
1076 |
]. |
|
1077 |
self contents:string. |
|
1078 |
aBoolean ifTrue:[ |
|
1079 |
self selectFromLine:1 col:1 toLine:1 col:string size |
|
1080 |
] |
|
1081 |
! |
|
1082 |
||
192 | 1083 |
initialText:aString |
1084 |
"set the initialText and select it" |
|
1085 |
||
1086 |
self initialText:aString selected:true |
|
1087 |
! |
|
1088 |
||
187 | 1089 |
initialText:aString selected:aBoolean |
1090 |
"set the initialText and select it if aBoolean is true" |
|
1091 |
||
1092 |
|len s| |
|
125 | 1093 |
|
187 | 1094 |
leftOffset := 0. |
1095 |
(s := aString) notNil ifTrue:[ |
|
1096 |
s := s asString |
|
1097 |
]. |
|
1098 |
self contents:s. |
|
1099 |
aBoolean ifTrue:[ |
|
1100 |
(len := s size) ~~ 0 ifTrue:[ |
|
1101 |
self selectFromLine:1 col:1 toLine:1 col:len |
|
1102 |
] |
|
1103 |
] |
|
1104 |
! |
|
1105 |
||
192 | 1106 |
list:someText |
1107 |
"low level access to the underlying contents' list. |
|
1108 |
Redefined to force text to 1 line, and notify dependents |
|
1109 |
of any changed extent-wishes (for automatic box resizing)." |
|
1110 |
||
1111 |
|l oldWidth| |
|
187 | 1112 |
|
192 | 1113 |
l := someText. |
1114 |
l size > 1 ifTrue:[ |
|
1115 |
l := OrderedCollection with:(l at:1) |
|
1116 |
]. |
|
1117 |
oldWidth := self widthOfContents. |
|
1118 |
super list:l. |
|
1119 |
self widthOfContents ~~ oldWidth ifTrue:[ |
|
1120 |
self changed:#preferredExtent |
|
1121 |
] |
|
187 | 1122 |
! |
1123 |
||
1124 |
stringValue |
|
1125 |
"alias for #contents - for compatibility with ST-80's InputField" |
|
1126 |
||
1127 |
^ self contents |
|
1128 |
! ! |
|
1129 |
||
1130 |
!EditField methodsFor:'accessing-look'! |
|
125 | 1131 |
|
155 | 1132 |
maxChars |
1133 |
"return the maximum number of characters that are allowed in |
|
1134 |
the field. |
|
1135 |
A limit of nil means: unlimited. This is the default." |
|
1136 |
||
1137 |
^ lengthLimit |
|
1138 |
||
1139 |
"Modified: 6.9.1995 / 13:43:33 / claus" |
|
1140 |
! |
|
1141 |
||
125 | 1142 |
maxChars:aNumberOrNil |
1143 |
"set the maximum number of characters that are allowed in |
|
1144 |
the field. Additional input will be ignored by the field. |
|
1145 |
A limit of nil means: unlimited. This is the default. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1146 |
If set, a lengthLimit must be defined before any contents is placed |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1147 |
into the field, because the contents is not cut when the max is |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1148 |
changed later. I.e. it should be set early after creation of the field. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1149 |
|
125 | 1150 |
This method has been renamed from #lengthLimit: for ST-80 |
1151 |
compatibility." |
|
1152 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1153 |
lengthLimit := aNumberOrNil. |
187 | 1154 |
! |
1155 |
||
192 | 1156 |
passwordCharacter |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1157 |
"return the passwordCharacter; |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1158 |
If nonNil, that one is replacing typed input |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1159 |
(for secret input)" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1160 |
|
192 | 1161 |
^ passwordCharacter |
0 | 1162 |
|
192 | 1163 |
"Modified: 6.9.1995 / 12:25:39 / claus" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1164 |
"Modified: 16.12.1995 / 16:24:25 / cg" |
125 | 1165 |
! |
1166 |
||
192 | 1167 |
passwordCharacter:aCharacter |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1168 |
"set the passwordCharacter; |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1169 |
If nonNil, that one is replacing typed input |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1170 |
(for secret input)" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1171 |
|
192 | 1172 |
passwordCharacter := aCharacter |
97 | 1173 |
|
192 | 1174 |
"Modified: 6.9.1995 / 12:25:33 / claus" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1175 |
"Modified: 16.12.1995 / 16:24:33 / cg" |
38 | 1176 |
! ! |
1177 |
||
0 | 1178 |
!EditField methodsFor:'cursor drawing'! |
1179 |
||
155 | 1180 |
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg |
1181 |
startVisLineNr to:endVisLineNr do:[:visLine | |
|
1182 |
self drawVisibleLine:visLine with:fg and:bg |
|
1183 |
] |
|
1184 |
||
1185 |
"Modified: 6.9.1995 / 12:24:29 / claus" |
|
1186 |
! |
|
1187 |
||
0 | 1188 |
showCursor |
1189 |
"make cursor visible if currently invisible - but only if this |
|
1190 |
EditField is enabled" |
|
1191 |
||
1192 |
enabled ifTrue:[super showCursor] |
|
1193 |
! ! |
|
1194 |
||
1195 |
!EditField methodsFor:'cursor movement'! |
|
1196 |
||
125 | 1197 |
cursorCol:col |
1198 |
"redefined to lock the cursor at the end, if I have a lngthLimit" |
|
1199 |
||
1200 |
|c sz| |
|
1201 |
||
1202 |
c := col. |
|
1203 |
lengthLimit notNil ifTrue:[ |
|
1204 |
sz := lengthLimit. |
|
1205 |
c > sz ifTrue:[ |
|
1206 |
c := sz+1. |
|
1207 |
] |
|
1208 |
]. |
|
1209 |
super cursorCol:c |
|
1210 |
! |
|
1211 |
||
0 | 1212 |
cursorDown |
1213 |
"catch cursor movement" |
|
1214 |
||
1215 |
(cursorVisibleLine == nLinesShown) ifFalse:[ |
|
59 | 1216 |
super cursorDown |
0 | 1217 |
] |
192 | 1218 |
! |
1219 |
||
1220 |
cursorLine:line col:col |
|
1221 |
"catch cursor movement" |
|
1222 |
||
1223 |
super cursorLine:1 col:col |
|
1224 |
! ! |
|
1225 |
||
1226 |
!EditField methodsFor:'editing'! |
|
1227 |
||
1228 |
paste:someText |
|
1229 |
"redefined to force text to 1 line" |
|
1230 |
||
1231 |
super paste:someText. |
|
1232 |
list size > 1 ifTrue:[ |
|
1233 |
self deleteFromLine:2 toLine:(list size) |
|
1234 |
] |
|
0 | 1235 |
! ! |
1236 |
||
70 | 1237 |
!EditField methodsFor:'event handling'! |
19 | 1238 |
|
192 | 1239 |
buttonPress:button x:x y:y |
1240 |
"enable myself on mouse click" |
|
1241 |
||
333 | 1242 |
enabled ifFalse:[ |
1243 |
^ self |
|
1244 |
]. |
|
1245 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1246 |
clickAction notNil ifTrue:[ |
333 | 1247 |
clickAction value:self |
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1248 |
]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1249 |
super buttonPress:button x:x y:y |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1250 |
|
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1251 |
"/ enabled ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1252 |
"/ enabled := true. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1253 |
"/ super buttonPress:button x:x y:y. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1254 |
"/ enableAction notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1255 |
"/ enableAction value |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1256 |
"/ ] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1257 |
"/ ] ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1258 |
"/ super buttonPress:button x:x y:y |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1259 |
"/ ] |
333 | 1260 |
|
1261 |
"Modified: 9.2.1996 / 01:51:20 / cg" |
|
192 | 1262 |
! |
1263 |
||
1264 |
canHandle:aKey |
|
1265 |
"return true, if the receiver would like to handle aKey |
|
1266 |
(usually from another view, when the receiver is part of |
|
1267 |
a more complex dialog box). |
|
1268 |
We do return true here, since the editfield will handle |
|
1269 |
all keys. |
|
1270 |
OBSOLETE: dont use this anymore - its a leftover for the tableWidget" |
|
1271 |
||
1272 |
^ true |
|
1273 |
! |
|
1274 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1275 |
enableStateChange |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1276 |
enableChannel value ifTrue:[ |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1277 |
self enable |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1278 |
] ifFalse:[ |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1279 |
self disable |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1280 |
]. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1281 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1282 |
"Created: 16.12.1995 / 16:35:39 / cg" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1283 |
"Modified: 16.12.1995 / 16:36:13 / cg" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1284 |
! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1285 |
|
192 | 1286 |
focusIn |
1287 |
"got the explicit focus" |
|
1288 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1289 |
"/ enabled ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1290 |
"/ enabled := true. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1291 |
"/ super focusIn. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1292 |
"/ enableAction notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1293 |
"/ enableAction value |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1294 |
"/ ] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1295 |
"/ ] ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1296 |
"/ super focusIn |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1297 |
"/ ]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1298 |
^ super focusIn |
192 | 1299 |
! |
1300 |
||
125 | 1301 |
keyPress:key x:x y:y |
1302 |
"if keyHandler is defined, pass input; otherwise check for leave |
|
1303 |
keys" |
|
1304 |
||
490 | 1305 |
<resource: #keyboard (#Tab #Return #Find #FindNext #FindPrev |
1306 |
#DeleteLine #GotoLine #EndOfLine #EndOfText)> |
|
132 | 1307 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1308 |
|leave xCol newOffset newWidth s| |
125 | 1309 |
|
1310 |
enabled ifFalse:[ |
|
325 | 1311 |
^ self |
125 | 1312 |
]. |
1313 |
||
1314 |
(key == #DeleteLine) ifTrue:[ |
|
325 | 1315 |
Smalltalk at:#CopyBuffer put:(self contents). |
1316 |
self contents:''. ^ self |
|
125 | 1317 |
]. |
19 | 1318 |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
1319 |
leave := leaveKeys includes:key. |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
1320 |
|
125 | 1321 |
(key == #Tab) ifTrue:[ |
325 | 1322 |
tabAction notNil ifTrue:[tabAction value. ^ self]. |
1323 |
entryCompletionBlock notNil ifTrue:[ |
|
1324 |
s := self contents. |
|
1325 |
s isNil ifTrue:[ |
|
1326 |
s := '' |
|
1327 |
] ifFalse:[ |
|
1328 |
s := s asString |
|
1329 |
]. |
|
1330 |
entryCompletionBlock value:s. ^ self |
|
1331 |
] ifFalse:[ |
|
1332 |
acceptOnTab ifTrue:[ |
|
480 | 1333 |
self accept. |
325 | 1334 |
] |
1335 |
]. |
|
594 | 1336 |
leave ifFalse:[ |
1337 |
^ super keyPress:key x:x y:y |
|
1338 |
] |
|
125 | 1339 |
]. |
480 | 1340 |
|
125 | 1341 |
(key == #Return) ifTrue:[ |
325 | 1342 |
crAction notNil ifTrue:[crAction value. ^ self]. |
125 | 1343 |
]. |
480 | 1344 |
|
125 | 1345 |
leave ifTrue:[ |
325 | 1346 |
((key == #Return and:[acceptOnReturn]) |
480 | 1347 |
or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[ |
325 | 1348 |
self accept. |
1349 |
]. |
|
279 | 1350 |
|
325 | 1351 |
leaveAction notNil ifTrue:[ |
1352 |
^ leaveAction value:key |
|
1353 |
]. |
|
125 | 1354 |
|
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1355 |
(x notNil and:[x >= 0]) ifTrue:[ |
325 | 1356 |
" |
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1357 |
we do not handle this keyi directly. |
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1358 |
let superview know about the key that caused us to leave (maybe RETURN, DOWN, UP etc.... |
325 | 1359 |
" |
1360 |
(superView notNil and:[superView canHandle:key from:self]) ifTrue:[ |
|
1361 |
superView keyPress:key x:x y:y. |
|
1362 |
]. |
|
1363 |
]. |
|
1364 |
^ self |
|
19 | 1365 |
]. |
121 | 1366 |
|
125 | 1367 |
" |
1368 |
ignore some keys (if not a leaveKey) ... |
|
1369 |
" |
|
1370 |
(key == #Find) ifTrue:[^self]. |
|
1371 |
(key == #FindNext) ifTrue:[^self]. |
|
1372 |
(key == #FindPrev) ifTrue:[^self]. |
|
1373 |
(key == #GotoLine) ifTrue:[^self]. |
|
1374 |
||
1375 |
" |
|
1376 |
a normal key - let superclass's method insert it |
|
1377 |
" |
|
1378 |
super keyPress:key x:x y:y. |
|
1379 |
||
1380 |
" |
|
1381 |
for end-of-text, also move to end-of-line |
|
1382 |
" |
|
1383 |
key == #EndOfText ifTrue:[ |
|
325 | 1384 |
super keyPress:#EndOfLine x:x y:y. |
125 | 1385 |
]. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1386 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1387 |
self resizeOrScroll. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1388 |
|
594 | 1389 |
"Modified: 27.4.1996 / 17:01:43 / cg" |
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1390 |
"Modified: 2.5.1996 / 17:24:16 / stefan" |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1391 |
! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1392 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1393 |
resizeOrScroll |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1394 |
"helper for keyPress. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1395 |
Extracted for easier subclass redefinition." |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1396 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1397 |
|xCol newOffset newWidth| |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1398 |
|
125 | 1399 |
newWidth := self widthOfContents. |
1400 |
||
1401 |
" |
|
1402 |
should (& can) we resize ? |
|
1403 |
" |
|
1404 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset. |
|
1405 |
(xCol > (width * (5/6))) ifTrue:[ |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1406 |
self changed:#preferredExtent |
125 | 1407 |
] ifFalse:[ |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1408 |
newWidth < (width * (1/6)) ifTrue:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1409 |
self changed:#preferredExtent |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1410 |
] |
125 | 1411 |
]. |
1412 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1413 |
autoScrollHorizontally ifTrue:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1414 |
" |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1415 |
did someone react (i.e. has my extent changed) ? |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1416 |
(if not, we scroll horizontally) |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1417 |
" |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1418 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1419 |
(xCol > (width * (5/6))) ifTrue:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1420 |
newOffset := leftOffset + (width // 2). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1421 |
] ifFalse:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1422 |
(xCol < (width * (1/6))) ifTrue:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1423 |
newOffset := 0 max: leftOffset - (width // 2). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1424 |
] ifFalse:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1425 |
newOffset := leftOffset |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1426 |
] |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1427 |
]. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1428 |
newOffset ~~ leftOffset ifTrue:[ |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1429 |
self scrollHorizontalTo:newOffset. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1430 |
] |
125 | 1431 |
]. |
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1432 |
! |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1433 |
|
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1434 |
showFocus:explicit |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1435 |
"/ giving me the focus is loke clicking on me |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1436 |
"/ (tell my enterFieldGroup .... |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1437 |
|
343
a7b6fbfdc453
oops - explicit focusChange was broken
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1438 |
(enabled or:[explicit]) ifTrue:[ |
333 | 1439 |
clickAction notNil ifTrue:[clickAction value:self]. |
1440 |
self showCursor. |
|
1441 |
super showFocus:explicit |
|
1442 |
] |
|
1443 |
||
343
a7b6fbfdc453
oops - explicit focusChange was broken
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
1444 |
"Modified: 9.2.1996 / 20:49:48 / cg" |
192 | 1445 |
! ! |
1446 |
||
1447 |
!EditField methodsFor:'initialization'! |
|
1448 |
||
1449 |
editMenu |
|
506
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1450 |
|labels selectors shorties m| |
192 | 1451 |
|
1452 |
labels := #( |
|
333 | 1453 |
'copy' |
1454 |
'cut' |
|
1455 |
'paste' |
|
1456 |
). |
|
192 | 1457 |
|
506
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1458 |
selectors := #( |
333 | 1459 |
copySelection |
1460 |
cut |
|
1461 |
paste |
|
1462 |
). |
|
192 | 1463 |
|
506
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1464 |
shorties := #( |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1465 |
#Copy |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1466 |
#Cut |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1467 |
#Paste |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1468 |
). |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1469 |
|
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1470 |
(acceptAction notNil |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1471 |
or:[model notNil and:[changeMsg notNil]]) ifTrue:[ |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1472 |
labels := labels , #( |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1473 |
'-' |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1474 |
'accept' |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1475 |
). |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1476 |
selectors := selectors , #( |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1477 |
nil |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1478 |
#accept |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1479 |
). |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1480 |
shorties := shorties , #( |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1481 |
nil |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1482 |
#Accept |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1483 |
). |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1484 |
]. |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1485 |
|
192 | 1486 |
m := PopUpMenu |
506
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1487 |
labels:(resources array:labels) |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1488 |
selectors:selectors |
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1489 |
accelerators:shorties. |
192 | 1490 |
|
1491 |
self hasSelection ifFalse:[ |
|
333 | 1492 |
m disableAll:#(copySelection cut) |
1493 |
]. |
|
1494 |
enabled ifFalse:[ |
|
1495 |
m disableAll:#(cut paste accept) |
|
192 | 1496 |
]. |
1497 |
||
1498 |
^ m |
|
333 | 1499 |
|
506
3273d75c3526
added accelerators; no Accept if there is no acceptAction/model
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
1500 |
"Modified: 20.3.1996 / 11:34:12 / cg" |
19 | 1501 |
! |
0 | 1502 |
|
192 | 1503 |
initStyle |
1504 |
super initStyle. |
|
1505 |
||
392
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
343
diff
changeset
|
1506 |
"/ DefaultFont notNil ifTrue:[font := DefaultFont on:device] |
81343306d796
eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents:
343
diff
changeset
|
1507 |
|
192 | 1508 |
DefaultBackgroundColor notNil ifTrue:[ |
1509 |
bgColor := DefaultBackgroundColor on:device. |
|
1510 |
self viewBackground:bgColor. |
|
1511 |
]. |
|
1512 |
fgColor := DefaultForegroundColor. |
|
1513 |
selectionFgColor := DefaultSelectionForegroundColor. |
|
1514 |
selectionBgColor := DefaultSelectionBackgroundColor. |
|
1515 |
! |
|
0 | 1516 |
|
192 | 1517 |
initialize |
1518 |
super initialize. |
|
1519 |
self height:(font height + font descent + (topMargin * 2)). |
|
1520 |
enabled := true. |
|
1521 |
fixedSize := true. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1522 |
autoScrollHorizontally := true. |
192 | 1523 |
nFullLinesShown := 1. |
1524 |
nLinesShown := 1. |
|
1525 |
immediateAccept := false. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
1526 |
acceptOnLeave := acceptOnReturn := acceptOnTab := true. |
192 | 1527 |
cursorShown := true. |
594 | 1528 |
leaveKeys isNil ifTrue:[ |
1529 |
leaveKeys := self class defaultLeaveKeys. |
|
1530 |
]. |
|
192 | 1531 |
cursorMovementWhenUpdating := #endOfLine |
594 | 1532 |
|
1533 |
"Modified: 27.4.1996 / 16:59:39 / cg" |
|
192 | 1534 |
! ! |
1535 |
||
1536 |
!EditField methodsFor:'private'! |
|
1537 |
||
1538 |
argForChangeMessage |
|
1539 |
"redefined to send use converted value (if I have one)" |
|
1540 |
||
1541 |
^ self editValue |
|
1542 |
! |
|
1543 |
||
1544 |
getListFromModel |
|
1545 |
"redefined to aquire the text via the aspectMsg - not the listMsg, |
|
1546 |
and to ignore updates resulting from my own change." |
|
1547 |
||
1548 |
" |
|
1549 |
ignore updates from my own change |
|
1550 |
" |
|
1551 |
lockUpdates ifTrue:[ |
|
1552 |
lockUpdates := false. |
|
1553 |
^ self |
|
1554 |
]. |
|
1555 |
||
1556 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
|
1557 |
self editValue:(model perform:aspectMsg). |
|
0 | 1558 |
] |
1559 |
! |
|
1560 |
||
192 | 1561 |
startAutoScrollDown:y |
1562 |
"no vertical scrolling in editfields" |
|
1563 |
||
1564 |
^ self |
|
1565 |
! |
|
1566 |
||
1567 |
startAutoScrollUp:y |
|
1568 |
"no vertical scrolling in editfields" |
|
1569 |
||
1570 |
^ self |
|
1571 |
! |
|
0 | 1572 |
|
192 | 1573 |
textChanged |
1574 |
"this is sent by mySelf (somewhere in a superclass) whenever |
|
1575 |
my contents has changed. |
|
1576 |
A good place to add immediateAccept functionality and check for the |
|
1577 |
lengthLimit." |
|
1578 |
||
1579 |
|string c| |
|
1580 |
||
1581 |
super textChanged. |
|
1582 |
string := self contents. |
|
1583 |
lengthLimit notNil ifTrue:[ |
|
1584 |
string size > lengthLimit ifTrue:[ |
|
1585 |
c := cursorCol. |
|
1586 |
self contents:(string copyTo:lengthLimit). |
|
1587 |
self flash. |
|
1588 |
self cursorCol:c. |
|
125 | 1589 |
] |
0 | 1590 |
]. |
192 | 1591 |
immediateAccept ifTrue:[ |
1592 |
self accept |
|
1593 |
] |
|
105 | 1594 |
! |
1595 |
||
192 | 1596 |
visibleAt:visLineNr |
1597 |
"return the string at lineNr for display. |
|
1598 |
If there is a password character, return a string consisting of those only." |
|
1599 |
||
1600 |
|s| |
|
105 | 1601 |
|
192 | 1602 |
s := super visibleAt:visLineNr. |
1603 |
passwordCharacter notNil ifTrue:[ |
|
1604 |
^ String new:(s size) withAll:passwordCharacter |
|
1605 |
]. |
|
1606 |
^ s |
|
1607 |
||
1608 |
"Modified: 6.9.1995 / 12:25:06 / claus" |
|
0 | 1609 |
! ! |
125 | 1610 |
|
192 | 1611 |
!EditField methodsFor:'queries'! |
1612 |
||
561 | 1613 |
isInputField |
1614 |
"return true, if the receiver is some kind of input view, |
|
1615 |
i.e. it should (can) be part of an enterGroup. |
|
1616 |
Return true here" |
|
1617 |
||
1618 |
^ true |
|
1619 |
||
1620 |
"Created: 4.3.1996 / 11:32:34 / cg" |
|
1621 |
! |
|
1622 |
||
468 | 1623 |
isInputView |
1624 |
"return true, if the receiver is some kind of input view, |
|
1625 |
i.e. it should (can) be part of an enterGroup. |
|
1626 |
Return true here" |
|
1627 |
||
1628 |
^ true |
|
1629 |
||
1630 |
"Created: 4.3.1996 / 11:32:34 / cg" |
|
1631 |
! |
|
1632 |
||
192 | 1633 |
preferredExtent |
1634 |
"return the preferred extent of this view. |
|
1635 |
That is the width of the string plus some extra, |
|
1636 |
but not wider than half of the screen" |
|
1637 |
||
1638 |
|string w f| |
|
125 | 1639 |
|
192 | 1640 |
string := self contents. |
1641 |
(string isNil or:[string isBlank]) ifTrue:[ |
|
1642 |
string := ' ' "/ just any string is ok ^ super preferredExtent |
|
1643 |
]. |
|
1644 |
f := font on:device. |
|
1645 |
w := ((f widthOf:string) * 1.5) rounded. |
|
1646 |
w := w min:(device width // 2). |
|
231 | 1647 |
"/ ^ w @ (f height * 1.5) rounded |
1648 |
^ w @ (f height + f descent + (margin * 2)"* 1.5") rounded |
|
192 | 1649 |
|
1650 |
"Modified: 6.9.1995 / 19:24:06 / claus" |
|
1651 |
! |
|
1652 |
||
1653 |
specClass |
|
1654 |
self class == EditField ifTrue:[^ InputFieldSpec]. |
|
1655 |
^ nil |
|
125 | 1656 |
|
192 | 1657 |
"Modified: 5.9.1995 / 17:28:27 / claus" |
325 | 1658 |
! |
1659 |
||
1660 |
tabMeansNextField |
|
1661 |
"return true, if Tab character should shift focus to the next field" |
|
1662 |
||
1663 |
"if I have a completionBlock, I want my Tabs ..." |
|
1664 |
||
1665 |
^ entryCompletionBlock isNil |
|
1666 |
||
1667 |
"Created: 7.2.1996 / 19:16:38 / cg" |
|
192 | 1668 |
! ! |
1669 |
||
1670 |
!EditField methodsFor:'realization'! |
|
1671 |
||
1672 |
realize |
|
1673 |
"scroll back to beginning when realized" |
|
1674 |
leftOffset := 0. |
|
1675 |
super realize |
|
125 | 1676 |
! ! |
192 | 1677 |
|
1678 |
!EditField methodsFor:'scrolling'! |
|
1679 |
||
1680 |
makeColVisible:col inLine:line |
|
1681 |
"dont scroll for the cursor, if its behond the text and a lengthLimit |
|
1682 |
is present." |
|
1683 |
||
1684 |
lengthLimit notNil ifTrue:[ |
|
1685 |
(col == cursorCol and:[col > lengthLimit]) ifTrue:[ |
|
1686 |
^ super makeColVisible:lengthLimit inLine:line |
|
1687 |
] |
|
1688 |
]. |
|
1689 |
^ super makeColVisible:col inLine:line |
|
1690 |
||
1691 |
"Modified: 6.9.1995 / 13:57:53 / claus" |
|
1692 |
! ! |
|
1693 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1694 |
!EditField methodsFor:'selections'! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1695 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1696 |
validateNewSelection |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1697 |
"make certain that only one line is ever selected" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1698 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1699 |
selectionEndLine > 1 ifTrue:[ |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1700 |
selectionEndLine := 2. selectionEndCol := 0 |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1701 |
]. |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1702 |
! ! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1703 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1704 |
!EditField class methodsFor:'documentation'! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1705 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1706 |
version |
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1707 |
^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.57 1996-05-02 16:33:21 stefan Exp $' |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1708 |
! ! |