author | Claus Gittinger <cg@exept.de> |
Mon, 13 Aug 2018 09:43:00 +0200 | |
changeset 6391 | 935a745d3c55 |
parent 6389 | 93eb877ae6f7 |
child 6392 | 22ceac28ebca |
permissions | -rw-r--r-- |
6305 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1990 by Claus Gittinger |
59 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2193
58666d1d312c
Channels moved to superclass (#destroy)
Stefan Vogel <sv@exept.de>
parents:
2130
diff
changeset
|
14 |
"{ Package: 'stx:libwidg' }" |
58666d1d312c
Channels moved to superclass (#destroy)
Stefan Vogel <sv@exept.de>
parents:
2130
diff
changeset
|
15 |
|
5240 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
EditTextView subclass:#EditField |
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
19 |
instanceVariableNames:'leaveAction enabled clickAction crAction tabAction converter |
209
7a6db7fac566
dont allow multiline selections in EditField
Claus Gittinger <cg@exept.de>
parents:
192
diff
changeset
|
20 |
leaveKeys immediateAccept acceptOnLeave acceptOnReturn |
979 | 21 |
lengthLimit entryCompletionBlock entryCompletionCharacter |
2130
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
22 |
passwordCharacter autoScrollHorizontally acceptOnTab |
3216 | 23 |
acceptOnLostFocus acceptOnPointerLeave acceptIfUnchanged leaveKey |
4720 | 24 |
doubleClickAction emptyFieldReplacementText leaveKeyActions' |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
25 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
4013 | 26 |
DefaultSelectionForegroundColor DefaultSelectionBackgroundColor |
27 |
DefaultBorderColor DefaultBorderWidth DefaultLevel' |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
28 |
poolDictionaries:'' |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
29 |
category:'Views-Text' |
0 | 30 |
! |
31 |
||
892 | 32 |
!EditField class methodsFor:'documentation'! |
19 | 33 |
|
38 | 34 |
copyright |
35 |
" |
|
36 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
59 | 37 |
All Rights Reserved |
38 | 38 |
|
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! |
|
47 |
||
19 | 48 |
documentation |
49 |
" |
|
38 | 50 |
an editable text-field. Realized by using an EditTextView, |
51 |
and forcing its size to 1 line - disabling cursor movement |
|
52 |
in the vertical direction. |
|
121 | 53 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
54 |
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
|
55 |
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
|
56 |
(especially: #contents / #contents:). |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
57 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
58 |
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
|
59 |
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
|
60 |
is extracted actively by someone else. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
61 |
|
2737 | 62 |
accepting: |
63 |
The opposite way to use editFields is to connect them to a model |
|
64 |
and let the field notify changes to it. |
|
65 |
This notification is called ``accepting''. |
|
66 |
Unless accepted, the models value is not updated from the editFields contents |
|
67 |
this default is the normal operation and way things should work, since most |
|
68 |
uses of editFields are not interested in every individual change |
|
69 |
(i.e. getting each keyStroke when a long number is entered). |
|
70 |
The default behavior is to ``accept'' when either return or a cursorUp/Down |
|
71 |
key is pressed in a field. |
|
72 |
However, the field can setup to accept/not accept on leave, on return |
|
73 |
or on each individual key input. |
|
6233 | 74 |
See the method's #acceptOnLeave: / #acceptOnReturn: / #immediateAccept. |
2737 | 75 |
|
76 |
In addition, the set of keys which are considered ``leaveKeys'' can be |
|
77 |
specified by #leaveKeys: (in case you need keys other than Return, CursorUp/Down). |
|
78 |
||
79 |
models value vs. field contents: |
|
80 |
Although the field internally keeps its contents as some string object, |
|
81 |
the application may prefer to think of numbers, floats, yes/no values etc. |
|
82 |
To support this, a converter may defined, which is responsible for conversion of |
|
83 |
strings to/from the models domain value. |
|
84 |
If present (i.e. nonNil), the converter is asked to convert a string to the models |
|
85 |
domain with #readValueFrom:aString and vice versa, a value to a string by #printStringFor:. |
|
86 |
The PrintConverter class already provides a number of standard conversions, see the examples. |
|
87 |
To access a converted value directly (i.e. not via the model), use #editValue. |
|
88 |
||
89 |
grouping: |
|
90 |
Individual fields do not know about being included in a group. This must be arranged on the |
|
91 |
outside, by placing multiple fields into an EnterFieldGroup. |
|
92 |
This groupObject keeps a reference to one active field, and forwards input from any other |
|
93 |
field to the active one. Also have a look at the examples for this. |
|
94 |
||
95 |
input completion: |
|
96 |
To support input completion (i.e. filename completion, classname completion etc.), |
|
97 |
a completionBlock can be defined which (if non-nil) is evaluated when the completion-key |
|
98 |
is pressed and its value is taken as the new field-contents. |
|
99 |
The physical completion-key is the Tab key (this one cannot be defined by |
|
100 |
the keyboardTranslation mechanism, since that would disable the Tab-key on regular text views. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
101 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
102 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
103 |
|
586 | 104 |
[Instance variables:] |
121 | 105 |
|
106 |
leaveAction <Block | nil> if non-nil, this is evaluated with |
|
586 | 107 |
the key (#Return, #CursorUp etc.) when |
108 |
the field is left via keyboard keys. |
|
109 |
(fieldGroups use this to decide which |
|
110 |
field has to be enabled next) |
|
121 | 111 |
|
112 |
enabled <Boolean> if false, input is ignored. |
|
113 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
114 |
clickAction <Block | nil> action performed if the field is |
586 | 115 |
clicked upon. |
116 |
(this is used by the group to |
|
117 |
set the active field to the clicked upon field) |
|
121 | 118 |
|
119 |
crAction <Block | nil> if non-nil, keyboard input of a cr are not |
|
586 | 120 |
handled specially, instead this block is evaluated |
121 |
(however, this block can perform additional checks and send |
|
122 |
a #accept then) |
|
121 | 123 |
|
124 |
tabAction <Block | nil> if non-nil, keyboard input of a tab character |
|
586 | 125 |
is not entered into the text, instead this block |
126 |
is evaluated. Also, no input completion is performed if |
|
127 |
tabAction is nonNil. |
|
121 | 128 |
|
129 |
converter <PrintConverter | nil> if non-nil, this is supposed to convert between |
|
586 | 130 |
the object and its printed representation and vice versa. |
131 |
Defaults to nil i.e. assume that strings are edited. |
|
121 | 132 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
133 |
leaveKeys <Collection> keys which are interpreted as 'leaving the field' |
122 | 134 |
|
125 | 135 |
immediateAccept <Boolean> if true, every change of the text is immediately |
586 | 136 |
forwarded to the model/acceptBlock. If false, |
137 |
the changed value is only stored in the model |
|
138 |
if the field is left or accepted. |
|
139 |
Default is false. |
|
122 | 140 |
|
141 |
acceptOnLeave <Boolean> if true, leaving the field (via cursor keys) |
|
586 | 142 |
automatically accepts the value into the model. |
143 |
Default is true. |
|
122 | 144 |
|
145 |
acceptOnReturn <Boolean> if true, leaving the field via return |
|
586 | 146 |
automatically accepts the value into the model. |
147 |
Default is true. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
148 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
149 |
acceptOnTab <Boolean> if true, the Tab key accepts and leaves the field. |
586 | 150 |
If false, Tabs are entered into the contents field like |
151 |
ordinary non-control keys. |
|
152 |
AcceptOnTab is ignored if the entryCompletion block is nonNil. |
|
153 |
Default is true. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
154 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
155 |
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
|
156 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
157 |
entryCompletionBlock <BlockOrNil> if non-nil, this is evaluated to complete the entry |
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
158 |
when <entryCompletionCharacter> is pressed. |
586 | 159 |
Entry completion is used with Filenamefields or in the |
160 |
browser for classname/selector completion. |
|
161 |
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
|
162 |
|
2130
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
163 |
entryCompletionCharacter <CharacterOrNil> if non-nil AND entryCompletionBlock is nonNil, that one |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
164 |
is evaluated for completion. Typically used to complete |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
165 |
a fileName (also, classNames in the browser) |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
166 |
Default is #Tab. |
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
167 |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
168 |
passwordCharacter <CharacterOrNil> if non-nil, typed input is replaced by this character |
586 | 169 |
for display. Used for secret-input fields (such as password entry). |
170 |
Default is nil. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
171 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
172 |
|
586 | 173 |
[author:] |
174 |
Claus Gittinger |
|
175 |
||
176 |
[see also:] |
|
177 |
DialogBox |
|
594 | 178 |
EnterFieldGroup |
179 |
EnterBox EnterBox2 |
|
180 |
FilenameEditField EditTextView |
|
19 | 181 |
" |
120 | 182 |
! |
183 |
||
6167 | 184 |
examples |
120 | 185 |
" |
122 | 186 |
see more examples in EnterFieldGroup>>examples. |
187 |
||
188 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
189 |
Step-by-step introduction: |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
190 |
|
120 | 191 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
192 |
basic field in some view: |
594 | 193 |
[exBegin] |
333 | 194 |
|top field| |
120 | 195 |
|
333 | 196 |
top := StandardSystemView new. |
197 |
top extent:200@100. |
|
120 | 198 |
|
333 | 199 |
field := EditField origin:0.0@0.0 in:top. |
200 |
field width:1.0. 'let its height as-is'. |
|
120 | 201 |
|
333 | 202 |
top open |
594 | 203 |
[exEnd] |
120 | 204 |
|
122 | 205 |
|
125 | 206 |
forward input in topView to the field: |
207 |
(currently, the field does not know this - therefore, |
|
208 |
its been told here ... this may change) |
|
594 | 209 |
[exBegin] |
333 | 210 |
|top field| |
122 | 211 |
|
333 | 212 |
top := StandardSystemView new. |
213 |
top extent:200@100. |
|
122 | 214 |
|
333 | 215 |
field := EditField origin:0.0@0.0 in:top. |
216 |
field width:1.0. 'let its height as-is'. |
|
122 | 217 |
|
333 | 218 |
top delegate:(KeyboardForwarder toView:field). |
219 |
field hasKeyboardFocus:true. |
|
220 |
top open |
|
594 | 221 |
[exEnd] |
122 | 222 |
|
223 |
||
125 | 224 |
to make it look better: set some inset: |
594 | 225 |
[exBegin] |
333 | 226 |
|top field spacing| |
120 | 227 |
|
333 | 228 |
top := StandardSystemView new. |
229 |
top extent:200@100. |
|
120 | 230 |
|
333 | 231 |
spacing := View viewSpacing. |
232 |
field := EditField origin:(0.0 @ spacing) in:top. |
|
233 |
field width:1.0. 'let its height as-is'. |
|
234 |
field leftInset:spacing; rightInset:spacing. |
|
120 | 235 |
|
333 | 236 |
top open |
594 | 237 |
[exEnd] |
120 | 238 |
|
122 | 239 |
|
120 | 240 |
give it an initial contents: |
594 | 241 |
[exBegin] |
333 | 242 |
|top field| |
120 | 243 |
|
333 | 244 |
top := StandardSystemView new. |
245 |
top extent:200@100. |
|
120 | 246 |
|
594 | 247 |
field := EditField origin:(0.0 @ 0.0) in:top. |
6167 | 248 |
field width:1.0. |
120 | 249 |
|
333 | 250 |
field editValue:'hello world'. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
251 |
|
333 | 252 |
top open |
594 | 253 |
[exEnd] |
120 | 254 |
|
122 | 255 |
|
125 | 256 |
have it preselected: |
594 | 257 |
[exBegin] |
333 | 258 |
|top field| |
120 | 259 |
|
333 | 260 |
top := StandardSystemView new. |
261 |
top extent:200@100. |
|
120 | 262 |
|
333 | 263 |
field := EditField origin:(0.0 @ 0.0) in:top. |
6167 | 264 |
field width:1.0. |
333 | 265 |
field editValue:'hello world' selected:true. |
120 | 266 |
|
333 | 267 |
top open |
594 | 268 |
[exEnd] |
120 | 269 |
|
122 | 270 |
|
120 | 271 |
have part of it preselected: |
594 | 272 |
[exBegin] |
333 | 273 |
|top field| |
120 | 274 |
|
333 | 275 |
top := StandardSystemView new. |
276 |
top extent:200@100. |
|
120 | 277 |
|
333 | 278 |
field := EditField origin:(0.0 @ 0.0) in:top. |
6167 | 279 |
field width:1.0. |
120 | 280 |
|
333 | 281 |
field editValue:'hello world'. |
282 |
field selectFromCharacterPosition:1 to:5. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
283 |
|
333 | 284 |
top open |
594 | 285 |
[exEnd] |
120 | 286 |
|
122 | 287 |
|
125 | 288 |
set a size limit: |
594 | 289 |
[exBegin] |
333 | 290 |
|top field| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
291 |
|
333 | 292 |
top := StandardSystemView new. |
293 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
294 |
|
333 | 295 |
field := EditField origin:(0.0 @ 0.0) in:top. |
6167 | 296 |
field width:1.0. |
333 | 297 |
field editValue:'hello'. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
298 |
|
333 | 299 |
field maxChars:8. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
300 |
|
333 | 301 |
top open |
594 | 302 |
[exEnd] |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
303 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
304 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
305 |
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
|
306 |
notice: you may prefer a constant-pitch font (such as courier): |
594 | 307 |
[exBegin] |
333 | 308 |
|top field| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
309 |
|
333 | 310 |
top := StandardSystemView new. |
311 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
312 |
|
333 | 313 |
field := EditField origin:(0.0 @ 0.0) in:top. |
6167 | 314 |
field innerWidth:(field font widthOf:'00000000'). |
333 | 315 |
field editValue:'12345678'. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
316 |
|
333 | 317 |
field maxChars:8. |
318 |
field autoScroll:false. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
319 |
|
333 | 320 |
top open |
594 | 321 |
[exEnd] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
322 |
|
125 | 323 |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
324 |
enable / disable: |
594 | 325 |
[exBegin] |
333 | 326 |
|top panel check field ena| |
327 |
||
328 |
top := StandardSystemView new. |
|
329 |
top extent:200@100. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
330 |
|
333 | 331 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
332 |
panel borderWidth:0. |
|
333 |
panel horizontalLayout:#left. |
|
334 |
panel horizontalInset:View viewSpacing. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
335 |
|
333 | 336 |
check := CheckBox label:'enable' in:panel. |
337 |
check turnOn. |
|
338 |
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
|
339 |
|
333 | 340 |
panel add:(View new height:30; borderWidth:0). |
125 | 341 |
|
333 | 342 |
field := EditField in:panel. |
6167 | 343 |
field width:1.0. |
333 | 344 |
field editValue:'hello'. |
6167 | 345 |
|
333 | 346 |
top open |
594 | 347 |
[exEnd] |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
348 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
349 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
350 |
enable / disable using a channel: |
594 | 351 |
[exBegin] |
333 | 352 |
|top panel check field ena| |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
353 |
|
333 | 354 |
top := StandardSystemView new. |
355 |
top extent:200@100. |
|
125 | 356 |
|
333 | 357 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
358 |
panel borderWidth:0. |
|
359 |
panel horizontalLayout:#left. |
|
360 |
panel horizontalInset:View viewSpacing. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
361 |
|
333 | 362 |
ena := true asValue. |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
363 |
|
333 | 364 |
check := CheckBox label:'enable' in:panel. |
365 |
check model:ena. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
366 |
|
333 | 367 |
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
|
368 |
|
333 | 369 |
field := EditField in:panel. |
370 |
field enableChannel:ena. |
|
6167 | 371 |
field width:1.0. |
333 | 372 |
field editValue:'hello'. |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
373 |
|
333 | 374 |
top open |
594 | 375 |
[exEnd] |
125 | 376 |
|
377 |
||
121 | 378 |
use a converter: |
125 | 379 |
- numbers (default to 0): |
594 | 380 |
[exBegin] |
381 |
|top field spacing| |
|
121 | 382 |
|
333 | 383 |
top := StandardSystemView new. |
384 |
top extent:200@100. |
|
121 | 385 |
|
594 | 386 |
spacing := View viewSpacing. |
387 |
||
388 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 389 |
field width:1.0. |
594 | 390 |
field horizontalInset:spacing. |
121 | 391 |
|
333 | 392 |
field converter:(PrintConverter new initForNumber). |
393 |
field editValue:1234. |
|
655 | 394 |
field acceptAction:[:value | Transcript showCR:value]. |
333 | 395 |
field crAction:[field accept. top destroy]. |
396 |
top open. |
|
594 | 397 |
[exEnd] |
121 | 398 |
|
399 |
- dates: |
|
594 | 400 |
[exBegin] |
401 |
|top field spacing| |
|
121 | 402 |
|
333 | 403 |
top := StandardSystemView new. |
404 |
top extent:200@100. |
|
121 | 405 |
|
594 | 406 |
spacing := View viewSpacing. |
407 |
||
408 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 409 |
field width:1.0. |
594 | 410 |
field horizontalInset:spacing. |
121 | 411 |
|
333 | 412 |
field converter:(PrintConverter new initForDate). |
413 |
field editValue:Date today. |
|
655 | 414 |
field acceptAction:[:value | Transcript showCR:value class name , ' ' , value printString]. |
333 | 415 |
field crAction:[field accept. top destroy]. |
416 |
top open. |
|
594 | 417 |
[exEnd] |
121 | 418 |
|
122 | 419 |
|
125 | 420 |
setting immediateAccept, makes the field update with every key: |
421 |
||
422 |
- immediate accept numbers, defaulting to nil: |
|
594 | 423 |
[exBegin] |
424 |
|top field spacing| |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
425 |
|
333 | 426 |
top := StandardSystemView new. |
427 |
top extent:200@100. |
|
121 | 428 |
|
594 | 429 |
spacing := View viewSpacing. |
430 |
||
431 |
field := EditField origin:0.0 @ spacing in:top. |
|
333 | 432 |
field width:1.0. |
594 | 433 |
field horizontalInset:spacing. |
121 | 434 |
|
333 | 435 |
field converter:(PrintConverter new initForNumberOrNil). |
436 |
field immediateAccept:true. |
|
437 |
field editValue:1234. |
|
655 | 438 |
field acceptAction:[:value | Transcript showCR:value]. |
333 | 439 |
field crAction:[field accept. top destroy]. |
440 |
top open. |
|
594 | 441 |
[exEnd] |
121 | 442 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
443 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
444 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
445 |
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
|
446 |
(i.e. actually: to the group): |
594 | 447 |
[exBegin] |
333 | 448 |
|top field1 field2 field3 group| |
121 | 449 |
|
122 | 450 |
|
333 | 451 |
top := StandardSystemView new. |
452 |
top extent:200@100. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
453 |
|
333 | 454 |
field1 := EditField origin:(0.0 @ 0.0) in:top. |
455 |
field1 width:1.0. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
456 |
|
333 | 457 |
field2 := EditField origin:(0.0 @ 0.0) in:top. |
458 |
field2 width:0.5. |
|
459 |
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
|
460 |
|
333 | 461 |
field3 := EditField origin:(0.5 @ 0.0) in:top. |
462 |
field3 width:0.5. |
|
463 |
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
|
464 |
|
333 | 465 |
group := EnterFieldGroup new. |
466 |
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
|
467 |
|
333 | 468 |
top delegate:(KeyboardForwarder to:group). |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
469 |
|
333 | 470 |
top open. |
594 | 471 |
[exEnd] |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
472 |
|
6167 | 473 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
474 |
in addition: tell the group to close when the last field is left: |
594 | 475 |
[exBegin] |
333 | 476 |
|top field1 field2 field3 group| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
477 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
478 |
|
333 | 479 |
top := StandardSystemView new. |
480 |
top extent:200@100. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
481 |
|
333 | 482 |
field1 := EditField origin:(0.0 @ 0.0) in:top. |
483 |
field1 width:1.0. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
484 |
|
333 | 485 |
field2 := EditField origin:(0.0 @ 0.0) in:top. |
486 |
field2 width:0.5. |
|
487 |
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
|
488 |
|
333 | 489 |
field3 := EditField origin:(0.5 @ 0.0) in:top. |
490 |
field3 width:0.5. |
|
491 |
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
|
492 |
|
333 | 493 |
group := EnterFieldGroup new. |
494 |
group add:field1; add:field2; add:field3. |
|
495 |
group leaveAction:[top destroy]. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
496 |
|
333 | 497 |
top delegate:(KeyboardForwarder to:group). |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
498 |
|
333 | 499 |
top open. |
594 | 500 |
[exEnd] |
127 | 501 |
|
502 |
||
120 | 503 |
use a model: |
504 |
(see changing model value in inspector when return is pressed in the field) |
|
594 | 505 |
[exBegin] |
333 | 506 |
|top field model| |
120 | 507 |
|
333 | 508 |
model := 'hello world' asValue. |
120 | 509 |
|
333 | 510 |
top := StandardSystemView new. |
511 |
top extent:200@100. |
|
120 | 512 |
|
333 | 513 |
field := EditField origin:(0.0 @ 0.0) in:top. |
514 |
field width:1.0. |
|
515 |
field model:model. |
|
516 |
field acceptOnReturn:true. |
|
120 | 517 |
|
333 | 518 |
top open. |
519 |
model inspect. |
|
594 | 520 |
[exEnd] |
121 | 521 |
|
122 | 522 |
|
892 | 523 |
like above, but also accept the value, when the focus is changed |
894 | 524 |
(i.e. out of the input field): |
892 | 525 |
(see changing model value in inspector) |
526 |
[exBegin] |
|
527 |
|top field model| |
|
528 |
||
529 |
model := 'hello world' asValue. |
|
530 |
||
531 |
top := StandardSystemView new. |
|
532 |
top extent:200@100. |
|
533 |
||
534 |
field := EditField origin:(0.0 @ 0.0) in:top. |
|
535 |
field width:1.0. |
|
536 |
field model:model. |
|
537 |
field acceptOnLostFocus:true. |
|
538 |
||
539 |
top open. |
|
894 | 540 |
InspectorView openOn:model monitor:'value'. |
892 | 541 |
[exEnd] |
542 |
||
543 |
||
127 | 544 |
two views on the same model (each accepts on return): |
594 | 545 |
[exBegin] |
333 | 546 |
|top1 top2 field1 field2 model| |
121 | 547 |
|
333 | 548 |
model := 'hello world' asValue. |
121 | 549 |
|
333 | 550 |
top1 := StandardSystemView new. |
551 |
top1 extent:200@100. |
|
552 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
553 |
field1 width:1.0. |
|
554 |
field1 model:model. |
|
555 |
field1 acceptOnReturn:true. |
|
556 |
top1 open. |
|
121 | 557 |
|
333 | 558 |
top2 := StandardSystemView new. |
559 |
top2 extent:200@100. |
|
560 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
561 |
field2 width:1.0. |
|
562 |
field2 model:model. |
|
563 |
field2 acceptOnReturn:true. |
|
564 |
top2 open. |
|
594 | 565 |
[exEnd] |
121 | 566 |
|
127 | 567 |
two views on the same model (no accept on return): |
594 | 568 |
[exBegin] |
333 | 569 |
|top1 top2 field1 field2 model| |
127 | 570 |
|
333 | 571 |
model := 'hello world' asValue. |
127 | 572 |
|
333 | 573 |
top1 := StandardSystemView new. |
574 |
top1 extent:200@100. |
|
575 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
576 |
field1 width:1.0. |
|
577 |
field1 model:model; acceptOnReturn:false. |
|
578 |
top1 open. |
|
127 | 579 |
|
333 | 580 |
top2 := StandardSystemView new. |
581 |
top2 extent:200@100. |
|
582 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
583 |
field2 width:1.0. |
|
584 |
field2 model:model; acceptOnReturn:false. |
|
585 |
top2 open. |
|
594 | 586 |
[exEnd] |
127 | 587 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
588 |
with immediate accept (every key updates the model): |
594 | 589 |
[exBegin] |
333 | 590 |
|top1 top2 field1 field2 model| |
125 | 591 |
|
333 | 592 |
model := 'hello world' asValue. |
125 | 593 |
|
333 | 594 |
top1 := StandardSystemView new. |
595 |
top1 extent:200@100. |
|
596 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
597 |
field1 width:1.0. |
|
598 |
field1 model:model; immediateAccept:true. |
|
599 |
top1 open. |
|
125 | 600 |
|
333 | 601 |
top2 := StandardSystemView new. |
602 |
top2 extent:200@100. |
|
603 |
field2 := EditField origin:(0.0 @ 0.0) in:top2. |
|
604 |
field2 width:1.0. |
|
605 |
field2 model:model; immediateAccept:true. |
|
606 |
top2 open. |
|
594 | 607 |
[exEnd] |
122 | 608 |
|
121 | 609 |
just an example; a checkBox and an editField on the same model: |
594 | 610 |
[exBegin] |
333 | 611 |
|top1 top2 field1 box model| |
121 | 612 |
|
333 | 613 |
model := false asValue. |
121 | 614 |
|
333 | 615 |
top1 := StandardSystemView new. |
616 |
top1 extent:200@100. |
|
617 |
field1 := EditField origin:(0.0 @ 0.0) in:top1. |
|
618 |
field1 width:1.0. |
|
619 |
field1 converter:(PrintConverter new initForYesNo). |
|
620 |
field1 model:model. |
|
621 |
top1 open. |
|
121 | 622 |
|
333 | 623 |
top2 := StandardSystemView new. |
624 |
top2 extent:200@100. |
|
625 |
box := CheckBox on:model. |
|
626 |
box label:'on/off'. |
|
627 |
top2 add:box. |
|
628 |
top2 open. |
|
121 | 629 |
|
333 | 630 |
model inspect. |
594 | 631 |
[exEnd] |
125 | 632 |
|
633 |
||
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
634 |
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
|
635 |
(the fields are connected by a group to allow tabbing) |
594 | 636 |
[exBegin] |
6167 | 637 |
|top panel group field1 field2 field3 box |
594 | 638 |
v1 v2 v3 spacing| |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
639 |
|
333 | 640 |
v1 := true asValue. |
641 |
v2 := 'some string' asValue. |
|
642 |
v3 := 1.2 asValue. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
643 |
|
333 | 644 |
top := StandardSystemView new. |
645 |
top extent:200@100. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
646 |
|
333 | 647 |
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
|
648 |
|
594 | 649 |
spacing := View viewSpacing. |
650 |
||
333 | 651 |
field1 := EditField new. |
652 |
field1 width:1.0. |
|
594 | 653 |
field1 horizontalInset:spacing. |
333 | 654 |
field1 converter:(PrintConverter new initForYesNo). |
655 |
field1 model:v1. |
|
656 |
panel add:field1. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
657 |
|
333 | 658 |
field2 := EditField new. |
659 |
field2 width:1.0. |
|
594 | 660 |
field2 horizontalInset:spacing. |
333 | 661 |
field2 model:v2. |
662 |
panel add:field2. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
663 |
|
333 | 664 |
field3 := EditField new. |
665 |
field3 width:1.0. |
|
594 | 666 |
field3 horizontalInset:spacing. |
333 | 667 |
field3 converter:(PrintConverter new initForNumber). |
668 |
field3 model:v3. |
|
669 |
panel add:field3. |
|
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
670 |
|
333 | 671 |
group := EnterFieldGroup new. |
672 |
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
|
673 |
|
333 | 674 |
top openModal. |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
675 |
|
655 | 676 |
Transcript showCR:v1 value. |
677 |
Transcript showCR:v2 value. |
|
678 |
Transcript showCR:v3 value. |
|
594 | 679 |
[exEnd] |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
680 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
681 |
|
125 | 682 |
connecting fields: |
6167 | 683 |
update field2 whenever field1 is changed. |
125 | 684 |
(normally, the processing below (xChanged) is done in your application |
685 |
class, or in a complex model. For the demonstration below, we use |
|
686 |
a Plug to simulate the protocol.) |
|
594 | 687 |
[exBegin] |
333 | 688 |
|application top field1 field2 value1 value2| |
125 | 689 |
|
333 | 690 |
application := Plug new. |
691 |
application respondTo:#value1Changed |
|
692 |
with:[value2 value:(value1 value isNil ifTrue:[nil] |
|
693 |
ifFalse:[value1 value squared])]. |
|
125 | 694 |
|
333 | 695 |
value1 := 1 asValue. |
696 |
value2 := 1 asValue. |
|
125 | 697 |
|
333 | 698 |
top := Dialog new. |
699 |
top extent:200@200. |
|
125 | 700 |
|
333 | 701 |
(top addTextLabel:'some number:') layout:#left. |
702 |
top addVerticalSpace. |
|
125 | 703 |
|
6167 | 704 |
(top addInputFieldOn:value1 tabable:false) |
333 | 705 |
converter:(PrintConverter new initForNumberOrNil); |
706 |
immediateAccept:true. |
|
707 |
top addVerticalSpace. |
|
125 | 708 |
|
333 | 709 |
(top addTextLabel:'squared:') layout:#left. |
710 |
top addVerticalSpace. |
|
6167 | 711 |
(top addInputFieldOn:value2 tabable:false) |
333 | 712 |
converter:(PrintConverter new initForNumberOrNil). |
125 | 713 |
|
333 | 714 |
value1 onChangeSend:#value1Changed to:application. |
125 | 715 |
|
333 | 716 |
top openModeless. |
594 | 717 |
[exEnd] |
125 | 718 |
|
719 |
||
720 |
two-way connect: |
|
721 |
each field updates the other (notice, that we have to turn off |
|
722 |
onChange: notification, to avoid an endless notification cycle) |
|
594 | 723 |
[exBegin] |
333 | 724 |
|application top field1 field2 value1 value2| |
125 | 725 |
|
333 | 726 |
application := Plug new. |
727 |
application respondTo:#value1Changed |
|
728 |
with:[value2 retractInterestsFor:application. |
|
729 |
value2 value:(value1 value isNil ifTrue:[nil] |
|
730 |
ifFalse:[value1 value squared]). |
|
731 |
value2 onChangeSend:#value2Changed to:application. |
|
732 |
]. |
|
733 |
application respondTo:#value2Changed |
|
734 |
with:[value1 retractInterestsFor:application. |
|
735 |
value1 value:(value2 value isNil ifTrue:[nil] |
|
736 |
ifFalse:[value2 value sqrt]). |
|
737 |
value1 onChangeSend:#value1Changed to:application. |
|
738 |
]. |
|
125 | 739 |
|
333 | 740 |
value1 := 1 asValue. |
741 |
value2 := 1 asValue. |
|
125 | 742 |
|
333 | 743 |
top := Dialog new. |
744 |
top extent:200@200. |
|
125 | 745 |
|
333 | 746 |
(top addTextLabel:'some number:') layout:#left. |
747 |
top addVerticalSpace. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
748 |
|
6167 | 749 |
(top addInputFieldOn:value1 tabable:false) |
333 | 750 |
converter:(PrintConverter new initForNumberOrNil); |
751 |
immediateAccept:true. |
|
752 |
top addVerticalSpace. |
|
125 | 753 |
|
333 | 754 |
(top addTextLabel:'squared:') layout:#left. |
755 |
top addVerticalSpace. |
|
6167 | 756 |
(top addInputFieldOn:value2 tabable:false) |
333 | 757 |
converter:(PrintConverter new initForNumberOrNil); |
758 |
immediateAccept:true. |
|
125 | 759 |
|
333 | 760 |
value1 onChangeSend:#value1Changed to:application. |
761 |
value2 onChangeSend:#value2Changed to:application. |
|
125 | 762 |
|
333 | 763 |
top openModeless. |
594 | 764 |
[exEnd] |
120 | 765 |
" |
19 | 766 |
! ! |
0 | 767 |
|
892 | 768 |
!EditField class methodsFor:'defaults'! |
0 | 769 |
|
4028 | 770 |
defaultBorderColor |
771 |
^ DefaultBorderColor |
|
772 |
! |
|
773 |
||
774 |
defaultBorderWidth |
|
775 |
^ DefaultBorderWidth |
|
776 |
! |
|
777 |
||
125 | 778 |
defaultLeaveKeys |
128 | 779 |
"return the set of keys which are taken as leave-keys. |
780 |
If the field is in an enterFieldGroup, all leave keys will be |
|
781 |
forwarded to the group and possible step to the next/previous field. |
|
782 |
Also, if acceptOnLeave is true, leave keys will store the current |
|
783 |
value into their model (if any)" |
|
784 |
||
125 | 785 |
^ #(Return CursorUp CursorDown Next Previous Accept) |
786 |
! |
|
787 |
||
4507 | 788 |
defaultLevel |
789 |
^ DefaultLevel |
|
790 |
! |
|
791 |
||
192 | 792 |
defaultNumberOfLines |
793 |
"the number of lines in the field" |
|
794 |
||
795 |
^ 1 |
|
796 |
! |
|
797 |
||
59 | 798 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
799 |
"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
|
800 |
|
4013 | 801 |
<resource: #style (#'editField.foregroundColor' |
802 |
#'editField.backgroundColor' |
|
803 |
#'editField.selectionForegroundColor' |
|
4214 | 804 |
#'editField.selectionBackgroundColor' |
1354 | 805 |
#'editField.font')> |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
806 |
|
4910 | 807 |
DefaultForegroundColor := StyleSheet colorAt:'editField.foregroundColor' default:Color black. |
808 |
DefaultBackgroundColor := StyleSheet colorAt:'editField.backgroundColor' default:Color white. |
|
1834 | 809 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'editField.selectionForegroundColor' default:nil. |
810 |
DefaultSelectionForegroundColor isNil ifTrue:[ |
|
811 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor' default:DefaultBackgroundColor. |
|
812 |
]. |
|
813 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'editField.selectionBackgroundColor' default:nil. |
|
814 |
DefaultSelectionBackgroundColor isNil ifTrue:[ |
|
815 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor' default:DefaultForegroundColor. |
|
816 |
]. |
|
1354 | 817 |
DefaultFont := StyleSheet fontAt:'editField.font' default:nil. |
4013 | 818 |
DefaultBorderColor := StyleSheet colorAt:'editField.borderColor' default:nil. |
819 |
DefaultBorderWidth := StyleSheet at:'editField.borderWidth' default:nil. |
|
820 |
DefaultLevel := StyleSheet at:'editField.level' default:nil. |
|
59 | 821 |
|
822 |
" |
|
60 | 823 |
self updateStyleCache |
59 | 824 |
" |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
825 |
|
4214 | 826 |
"Modified: / 19-01-2011 / 22:34:35 / cg" |
0 | 827 |
! ! |
828 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
829 |
!EditField methodsFor:'accepting'! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
830 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
831 |
accept |
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
832 |
"accept the current contents by executing the accept-action and/or |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
833 |
changeMessage. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
834 |
Do this only if the contents of the EditField differs |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
835 |
from the printed representation of the model." |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
836 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
837 |
|string| |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
838 |
|
1108 | 839 |
acceptEnabled == false ifTrue:[ |
6268 | 840 |
self beepInEditor. |
1108 | 841 |
^ self |
842 |
]. |
|
843 |
||
2105 | 844 |
(acceptIfUnchanged not |
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
845 |
and:[model notNil |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
846 |
and:[(self convertEditValueToString:model value) = self contents]]) ifTrue:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
847 |
^ self |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
848 |
]. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
849 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
850 |
super accept. |
2105 | 851 |
|
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
852 |
"a typeconverter can convert different strings to the same value |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
853 |
('010' asInteger = '10' asInteger). |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
854 |
Show the common string representation ('10') of the value" |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
855 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
856 |
converter notNil ifTrue:[ |
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
857 |
string := converter printStringFor:self editValue. |
1108 | 858 |
string ~= self contents ifTrue:[ |
859 |
self contents:string. |
|
860 |
self flash |
|
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
861 |
]. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
862 |
]. |
1108 | 863 |
|
864 |
"Modified: 7.3.1997 / 11:06:00 / cg" |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
865 |
! ! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
866 |
|
192 | 867 |
!EditField methodsFor:'accessing-behavior'! |
125 | 868 |
|
2105 | 869 |
acceptIfUnchanged |
870 |
"return the acceptIfUnchanged flag setting. |
|
871 |
if set (the default), an accept notification is sent on accept, |
|
872 |
even if the fields value is the same. If cleared, |
|
873 |
the notification is suppressed, if the fields contents is the same." |
|
874 |
||
875 |
^ acceptIfUnchanged |
|
876 |
! |
|
877 |
||
878 |
acceptIfUnchanged:aBoolean |
|
879 |
"if set (the default), an accept notification is sent on accept, |
|
880 |
even if the fields value is the same. If cleared, |
|
881 |
the notification is suppressed, if the fields contents is the same." |
|
882 |
||
883 |
acceptIfUnchanged := aBoolean |
|
884 |
! |
|
885 |
||
2538
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
886 |
acceptOnLeave |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
887 |
"returnr the acceptOnLeave flag. The default is false. |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
888 |
If true, leaving the box (via return, cursor etc.) accepts my |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
889 |
string into the valueHolder (if any). |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
890 |
(actually, the set of keys can be specified with #leaveKeys:)" |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
891 |
|
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
892 |
^ acceptOnLeave |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
893 |
! |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
894 |
|
192 | 895 |
acceptOnLeave:aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
896 |
"set/clear the acceptOnLeave flag. The default is false. |
892 | 897 |
If true, leaving the box (via return, cursor etc.) accepts my |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
898 |
string into the valueHolder (if any). |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
899 |
(actually, the set of keys can be specified with #leaveKeys:)" |
125 | 900 |
|
192 | 901 |
acceptOnLeave := aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
902 |
|
892 | 903 |
"Modified: 11.12.1996 / 16:47:25 / cg" |
904 |
! |
|
905 |
||
3082 | 906 |
acceptOnLostFocus |
907 |
^ acceptOnLostFocus |
|
908 |
! |
|
909 |
||
892 | 910 |
acceptOnLostFocus:aBoolean |
911 |
"set/clear the acceptOnLostFocus flag. The default is false. |
|
912 |
If true, a lost focus (via mouse-pointer motion etc.) accepts my |
|
913 |
string into the valueHolder (if any)." |
|
914 |
||
915 |
acceptOnLostFocus := aBoolean |
|
916 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
917 |
"Modified: 16.12.1995 / 16:26:45 / cg" |
892 | 918 |
"Created: 11.12.1996 / 16:48:00 / cg" |
192 | 919 |
! |
920 |
||
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
921 |
acceptOnPointerLeave:aBoolean |
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
922 |
"set/clear the acceptOnPointerLeave flag. The default is false. |
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
923 |
If true, a pointer leave (via mouse-pointer motion etc.) accepts my |
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
924 |
string into the valueHolder (if any)." |
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
925 |
|
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
926 |
acceptOnPointerLeave := aBoolean |
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
927 |
|
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
928 |
"Modified: / 16.12.1995 / 16:26:45 / cg" |
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
929 |
"Created: / 28.6.1999 / 18:07:38 / cg" |
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
930 |
! |
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
931 |
|
192 | 932 |
acceptOnReturn:aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
933 |
"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
|
934 |
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
|
935 |
string into the valueHolder (if any)." |
192 | 936 |
|
937 |
acceptOnReturn := aBoolean |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
938 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
939 |
"Modified: 16.12.1995 / 16:25:34 / cg" |
125 | 940 |
! |
941 |
||
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
942 |
acceptOnTab:aBoolean |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
943 |
"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
|
944 |
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
|
945 |
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
|
946 |
(i.e. inserted into the contents)." |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
947 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
948 |
acceptOnTab := aBoolean |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
949 |
|
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
950 |
"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
|
951 |
! |
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
952 |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
953 |
autoScroll:aBoolean |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
954 |
"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
|
955 |
to make the cursor visible." |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
956 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
957 |
autoScrollHorizontally := aBoolean |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
958 |
! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
959 |
|
325 | 960 |
clickAction:aBlock |
961 |
"define an action to be evaluated when being clicked upon" |
|
962 |
||
963 |
clickAction := aBlock |
|
964 |
! |
|
965 |
||
2792 | 966 |
converter |
967 |
"return the converter (if any)." |
|
968 |
||
969 |
^ converter |
|
970 |
! |
|
971 |
||
972 |
converter:aConverter |
|
973 |
"set the converter. If non-nil, |
|
974 |
the converter is applied to the text to convert from the string |
|
975 |
representation to the actual object value and vice versa. |
|
976 |
The default converter is nil, meaning no-conversion |
|
977 |
(i.e. the edited object is the string itself." |
|
978 |
||
979 |
converter := aConverter |
|
6192 | 980 |
|
981 |
" |
|
982 |
|field model| |
|
983 |
||
984 |
model := 0.5 asValue. |
|
985 |
field := EditField new. |
|
986 |
field model:model. |
|
987 |
field converter:(PrintConverter new initForNumber). |
|
988 |
model onChangeEvaluate:[ Transcript showCR: model value ]. |
|
989 |
field open. |
|
990 |
" |
|
991 |
||
992 |
"Modified (comment): / 24-08-2017 / 16:16:20 / cg" |
|
2792 | 993 |
! |
994 |
||
192 | 995 |
crAction:aBlock |
996 |
"define an action to be evaluated when the return key is pressed." |
|
997 |
||
998 |
crAction := aBlock |
|
999 |
! |
|
125 | 1000 |
|
3216 | 1001 |
doubleClickAction:aBlock |
1002 |
"define an action to be evaluated when being double clicked upon" |
|
1003 |
||
1004 |
doubleClickAction := aBlock |
|
1005 |
! |
|
1006 |
||
1034 | 1007 |
enabled |
1008 |
"return true, if the field is enabled (i.e. accepts keyboard input)" |
|
1009 |
||
1010 |
^ enabled ? true |
|
1011 |
||
1012 |
! |
|
1013 |
||
1829 | 1014 |
enabled:aBoolean |
1015 |
"enable/disable the field; show/hide the cursor and allow/disallow input" |
|
1016 |
||
1017 |
enabled ~~ aBoolean ifTrue:[ |
|
1018 |
enabled := aBoolean. |
|
1019 |
self updateBackground. |
|
1020 |
super cursorShown:aBoolean |
|
1021 |
] |
|
1022 |
||
1023 |
"Modified: / 3.8.1998 / 17:52:18 / cg" |
|
1024 |
"Created: / 30.3.1999 / 15:19:17 / stefan" |
|
1025 |
"Modified: / 30.3.1999 / 16:00:43 / stefan" |
|
1026 |
! |
|
1027 |
||
2993 | 1028 |
entryCompletionBlock |
1029 |
"the action to be evaluated when Tab (EntryCompletionCharacter) is pressed. |
|
1030 |
The block gets the current contents and the field itself as optional arguments |
|
1031 |
(i.e. it can be a 0, 1 or 2-arg block)." |
|
1032 |
||
1033 |
"/ read comment in entryCompletionBlockHolder: on why the following kludge is present |
|
1034 |
entryCompletionBlock isBlock ifTrue:[ |
|
1035 |
^ entryCompletionBlock |
|
1036 |
]. |
|
1037 |
^ entryCompletionBlock value |
|
1038 |
! |
|
1039 |
||
2995 | 1040 |
entryCompletionBlock:aZeroOneOrTwoArgBlock |
2993 | 1041 |
"define an action to be evaluated when Tab (EntryCompletionCharacter) is pressed. |
2628 | 1042 |
The block gets the current contents and the field itself as optional arguments |
1043 |
(i.e. it can be a 0, 1 or 2-arg block)." |
|
192 | 1044 |
|
2995 | 1045 |
entryCompletionBlock := aZeroOneOrTwoArgBlock |
125 | 1046 |
! |
1047 |
||
2995 | 1048 |
entryCompletionBlockHolder:aZeroOneOrTwoArgBlock |
2993 | 1049 |
"a holder for an action to be evaluated when Tab (EntryCompletionCharacter) is pressed. |
1050 |
The block gets the current contents and the field itself as optional arguments |
|
1051 |
(i.e. it can be a 0, 1 or 2-arg block)." |
|
1052 |
||
1053 |
"/ for now (to avoid incompatibilities), misuse the existing |
|
6095 | 1054 |
"/ entryCompletionBlock and check if it's a holder. |
2993 | 1055 |
|
2995 | 1056 |
entryCompletionBlock := aZeroOneOrTwoArgBlock |
6095 | 1057 |
|
1058 |
"Modified (comment): / 13-02-2017 / 20:09:56 / cg" |
|
2993 | 1059 |
! |
1060 |
||
3990 | 1061 |
entryCompletionCharacter |
1062 |
"return the value of the instance variable 'entryCompletionCharacter' (automatically generated)" |
|
1063 |
||
1064 |
^ entryCompletionCharacter |
|
1065 |
! |
|
1066 |
||
192 | 1067 |
immediateAccept:aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1068 |
"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
|
1069 |
If true, every pressed key immediately accepts my |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1070 |
string into the valueHolder (if any)." |
155 | 1071 |
|
192 | 1072 |
immediateAccept := aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1073 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1074 |
"Modified: 16.12.1995 / 16:25:57 / cg" |
192 | 1075 |
! |
155 | 1076 |
|
995 | 1077 |
isAcceptOnLeave |
1078 |
"return the acceptOnLeave flag. The default is false. |
|
1079 |
If true, leaving the box (via return, cursor etc.) accepts my |
|
1080 |
string into the valueHolder (if any). |
|
1081 |
(actually, the set of keys can be specified with #leaveKeys:)" |
|
1082 |
||
1083 |
^ acceptOnLeave |
|
1084 |
||
1085 |
"Modified: 11.12.1996 / 16:47:25 / cg" |
|
1086 |
! |
|
1087 |
||
1088 |
isAcceptOnLostFocus |
|
1089 |
"return the acceptOnLostFocus flag. The default is false. |
|
1090 |
If true, a lost focus (via mouse-pointer motion etc.) accepts my |
|
1091 |
string into the valueHolder (if any)." |
|
1092 |
||
1093 |
^ acceptOnLostFocus |
|
1094 |
||
1095 |
"Modified: 16.12.1995 / 16:26:45 / cg" |
|
1096 |
"Created: 11.12.1996 / 16:48:00 / cg" |
|
1097 |
! |
|
1098 |
||
1099 |
isAcceptOnReturn |
|
1100 |
"return the acceptOnReturn flag. The default is false. |
|
1101 |
If true, leaving the box via return accepts my |
|
1102 |
string into the valueHolder (if any)." |
|
1103 |
||
1104 |
^ acceptOnReturn |
|
1105 |
||
1106 |
"Modified: 16.12.1995 / 16:25:34 / cg" |
|
1107 |
! |
|
1108 |
||
1109 |
isAcceptOnTab |
|
1110 |
"return the acceptOnTab flag. The default is true. |
|
1111 |
If true, a pressed Tab key accepts and leaves the box. |
|
1112 |
If false, the Tab key is treated like any normal input character |
|
1113 |
(i.e. inserted into the contents)." |
|
1114 |
||
1115 |
^ acceptOnTab |
|
1116 |
! |
|
1117 |
||
994 | 1118 |
isImmediateAccept |
1119 |
"return the immediateAccept flag. The default is false. |
|
1120 |
If true, every pressed key immediately accepts my |
|
1121 |
string into the valueHolder (if any)." |
|
1122 |
||
1123 |
^ immediateAccept |
|
1124 |
||
1125 |
"Modified: 16.12.1995 / 16:25:57 / cg" |
|
1126 |
! |
|
1127 |
||
192 | 1128 |
leaveAction:aBlock |
4720 | 1129 |
"define an action to be evaluated when field is left by a leave-key |
1130 |
(by default: return or cursor keys. |
|
1131 |
Actually, the set of keys can be specified with #leaveKeys: |
|
1132 |
On leave, the precedence of actions is: |
|
1133 |
1) explicit leaveAction per key |
|
1134 |
2) this general leaveAction |
|
1135 |
3) tab or return action |
|
1136 |
" |
|
192 | 1137 |
|
1138 |
leaveAction := aBlock |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1139 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1140 |
"Modified: 16.12.1995 / 16:26:36 / cg" |
155 | 1141 |
! |
1142 |
||
3990 | 1143 |
leaveKey |
1144 |
"only valid after the editField has been left via a leaveCharacter. |
|
1145 |
Allows for users of the EditField to advance the selection |
|
1146 |
(especially: DataSets to select next/prev if editor is left via CrsrUp/Down)" |
|
1147 |
||
1148 |
^ leaveKey |
|
1149 |
! |
|
1150 |
||
1997 | 1151 |
leaveKeys |
1998 | 1152 |
"return (a copy of) the collection of keys which are interpreted as leaveKeys. |
1153 |
I.e. those that make the field inactive and pass the focus to the next field |
|
1154 |
(and accept, if acceptOnLeave is true)" |
|
1997 | 1155 |
|
1156 |
^ leaveKeys copy |
|
1157 |
! |
|
1158 |
||
192 | 1159 |
leaveKeys:aCollectionOfKeySymbols |
1160 |
"define the set of keys which are interpreted as leaveKeys. |
|
1161 |
I.e. those that make the field inactive and accept (if acceptOnLeave is true). |
|
1162 |
The default is a set of #CursorUp, #CursorDown, #Next, #Prior and #Return." |
|
155 | 1163 |
|
192 | 1164 |
leaveKeys := aCollectionOfKeySymbols |
1165 |
! |
|
155 | 1166 |
|
594 | 1167 |
makeTabable |
1168 |
"arrange for Tab to accept & leave the field |
|
1169 |
If the field is part of a group, the next field gets the |
|
1170 |
input focus" |
|
1171 |
||
1172 |
leaveKeys isNil ifTrue:[ |
|
1173 |
leaveKeys := self class defaultLeaveKeys |
|
1174 |
]. |
|
1175 |
leaveKeys := leaveKeys copyWith:#Tab |
|
1176 |
||
1177 |
"Created: 27.4.1996 / 17:09:48 / cg" |
|
1178 |
! |
|
1179 |
||
4720 | 1180 |
onKey:aKey leaveWith:aBlock |
6389 | 1181 |
"arrange for aKey to leave the field and evaluate aBlock. |
4720 | 1182 |
On leave, the precedence of actions is: |
1183 |
1) explicit leaveAction per key |
|
1184 |
2) general leaveAction |
|
1185 |
3) tab or return action |
|
6389 | 1186 |
Can be used to arrange for cursorDown to pass focus to another widget, |
1187 |
or to override builtin ctrl- shortcuts. |
|
1188 |
The leave-action block will be called with 0,1 (the key) or 2 (self + key) arguments" |
|
4720 | 1189 |
|
4724 | 1190 |
leaveKeys := leaveKeys asOrderedCollection. |
4720 | 1191 |
leaveKeys add:aKey. |
1192 |
leaveKeyActions isNil ifTrue:[ |
|
1193 |
leaveKeyActions := Dictionary new. |
|
1194 |
]. |
|
1195 |
leaveKeyActions at:aKey put:aBlock. |
|
6389 | 1196 |
|
1197 |
"Modified (comment): / 09-08-2018 / 09:15:29 / Claus Gittinger" |
|
4720 | 1198 |
! |
1199 |
||
1609
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1200 |
readOnly:aBoolean |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1201 |
"make the text readonly or writable" |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1202 |
|
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1203 |
super readOnly:aBoolean. |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1204 |
self updateBackground. |
1609
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1205 |
|
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1206 |
"Created: / 26.7.1998 / 21:23:17 / cg" |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1207 |
"Modified: / 3.8.1998 / 17:52:38 / cg" |
1609
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1208 |
! |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1209 |
|
1842 | 1210 |
returnKeyIsFocusNext |
1211 |
"arrange for the return key to act as a focus-next key" |
|
1212 |
||
3975
73674d16fc63
copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1213 |
leaveKeys := leaveKeys copyAsOrderedCollection. |
1842 | 1214 |
leaveKeys remove:#Return ifAbsent:nil |
1215 |
! |
|
1216 |
||
192 | 1217 |
tabAction:aBlock |
1218 |
"define an action to be evaluated when the tabulator key is pressed." |
|
155 | 1219 |
|
192 | 1220 |
tabAction := aBlock |
594 | 1221 |
! |
1222 |
||
1223 |
tabKey:aKeySymbol |
|
1224 |
"arrange for aKeySymbol to accept & leave the field |
|
1225 |
If the field is part of a group, the next field gets the |
|
1226 |
input focus" |
|
1227 |
||
1228 |
leaveKeys isNil ifTrue:[ |
|
1229 |
leaveKeys := self class defaultLeaveKeys |
|
1230 |
]. |
|
1231 |
leaveKeys := leaveKeys copyWith:#Tab |
|
1232 |
||
1233 |
"Created: 27.4.1996 / 17:08:54 / cg" |
|
187 | 1234 |
! ! |
125 | 1235 |
|
187 | 1236 |
!EditField methodsFor:'accessing-contents'! |
125 | 1237 |
|
187 | 1238 |
contents |
1239 |
"return contents as a string |
|
1240 |
- redefined since EditFields hold only one line of text. |
|
1241 |
In your application, please use #editValue; |
|
1242 |
it uses a converter (if any) and is compatible to ST-80." |
|
1243 |
||
3706
d25f10e7b49b
#accept only, if the text field has been modified (DrawAdaptor compatibility)
Stefan Vogel <sv@exept.de>
parents:
3704
diff
changeset
|
1244 |
(list isEmptyOrNil) ifTrue:[^ '']. |
187 | 1245 |
^ list at:1 |
1246 |
! |
|
1247 |
||
125 | 1248 |
contents:someText |
1249 |
"set the contents from a string |
|
1250 |
- redefined to place the cursor to the end. |
|
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1251 |
In your application, please use #editValue: - |
125 | 1252 |
it uses a converter (if any) and is compatible to ST-80." |
1253 |
||
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1254 |
|newCol txt| |
187 | 1255 |
|
1256 |
newCol := cursorCol. |
|
1257 |
||
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1258 |
someText isNil ifTrue:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1259 |
txt := ''. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1260 |
] ifFalse:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1261 |
txt := someText asString. |
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1262 |
]. |
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1263 |
super contents:txt. |
125 | 1264 |
|
2130
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1265 |
(cursorMovementWhenUpdating == #endOfLine |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1266 |
or:[cursorMovementWhenUpdating == #endOfText |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1267 |
or:[cursorMovementWhenUpdating == #end]]) ifTrue:[ |
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1268 |
newCol := (txt size + 1). |
187 | 1269 |
] ifFalse:[ |
2130
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1270 |
(cursorMovementWhenUpdating == #beginOfLine |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1271 |
or:[cursorMovementWhenUpdating == #beginOfText |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1272 |
or:[cursorMovementWhenUpdating == #begin]]) ifTrue:[ |
1179 | 1273 |
newCol := 1 |
1274 |
] ifFalse:[ |
|
1275 |
"/ default: stay where it was |
|
1276 |
] |
|
187 | 1277 |
]. |
125 | 1278 |
|
187 | 1279 |
self cursorCol:newCol. |
1179 | 1280 |
|
2042 | 1281 |
"Modified: / 13.11.1999 / 13:50:30 / cg" |
125 | 1282 |
! |
1283 |
||
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1284 |
convertEditValueToString:aStringOrObject |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1285 |
"convert a aStringOrObject to a printed representation. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1286 |
If there is a converter, use it to convert |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1287 |
the object into a printed representation. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1288 |
Use asString to convert the object, |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1289 |
and used directly." |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1290 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1291 |
converter notNil ifTrue:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1292 |
^ converter printStringFor:aStringOrObject |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1293 |
]. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1294 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1295 |
aStringOrObject isNil ifTrue:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1296 |
^ ''. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1297 |
]. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1298 |
^ aStringOrObject asString. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1299 |
! |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1300 |
|
125 | 1301 |
editValue |
1302 |
"if the field edits a string, this is a name alias for #contents. |
|
1303 |
Otherwise, if there is a converter, return the edited string |
|
1304 |
converted to an appropriate object." |
|
1305 |
||
1306 |
|string| |
|
1307 |
||
1308 |
string := self contents. |
|
279 | 1309 |
string isNil ifTrue:[string := '']. |
125 | 1310 |
converter isNil ifTrue:[^ string]. |
1311 |
^ converter readValueFrom:string |
|
1312 |
! |
|
0 | 1313 |
|
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1314 |
editValue:anObject |
125 | 1315 |
"set the contents. If there is a converter, use it to convert |
1316 |
the object into a printed representation. |
|
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1317 |
Otherwise, convert anObject to a string using #asString |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1318 |
(this is equivalent to sending #contents:)." |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1319 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1320 |
self editValue:anObject selected:false |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1321 |
! |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1322 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1323 |
editValue:anObject selected:isSelected |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1324 |
"set the contents. If there is a converter, use it to convert |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1325 |
anObject into a printed representation. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1326 |
Otherwise, use anObject asString |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1327 |
(i.e. this is equivalent to sending #initialText:selected:)." |
125 | 1328 |
|
1329 |
|string| |
|
1330 |
||
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1331 |
string := self convertEditValueToString:anObject. |
125 | 1332 |
self contents:string. |
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1333 |
isSelected ifTrue:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1334 |
self selectFromLine:1 col:1 toLine:1 col:string size. |
125 | 1335 |
] |
1336 |
! |
|
1337 |
||
192 | 1338 |
initialText:aString |
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1339 |
"set the initialText and select it. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1340 |
Better use #editValue: - it uses the type converter." |
192 | 1341 |
|
1342 |
self initialText:aString selected:true |
|
1343 |
! |
|
1344 |
||
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1345 |
initialText:aString selected:isSelected |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1346 |
"set the initialText and select it if isSelected is true |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1347 |
Better use #editValue:selected: - it uses the type converter." |
187 | 1348 |
|
1349 |
|len s| |
|
125 | 1350 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1351 |
viewOrigin := 0 @ viewOrigin y. |
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1352 |
|
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1353 |
self contents:aString. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1354 |
isSelected ifTrue:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1355 |
s := self contents. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1356 |
len := s size. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1357 |
len ~~ 0 ifTrue:[ |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1358 |
self selectFromLine:1 col:1 toLine:1 col:len |
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1359 |
] |
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1360 |
]. |
187 | 1361 |
! |
1362 |
||
192 | 1363 |
list:someText |
1364 |
"low level access to the underlying contents' list. |
|
1365 |
Redefined to force text to 1 line, and notify dependents |
|
1366 |
of any changed extent-wishes (for automatic box resizing)." |
|
1367 |
||
6195 | 1368 |
|l oldWidth newWidth| |
187 | 1369 |
|
192 | 1370 |
l := someText. |
4992 | 1371 |
l notEmptyOrNil ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1372 |
l := OrderedCollection with:(l at:1) |
192 | 1373 |
]. |
1374 |
oldWidth := self widthOfContents. |
|
1375 |
super list:l. |
|
6195 | 1376 |
newWidth := self widthOfContents. |
1377 |
(newWidth > oldWidth and:[newWidth > self innerWidth]) ifTrue:[ |
|
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1378 |
self changedPreferredBounds:nil |
192 | 1379 |
] |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1380 |
|
6195 | 1381 |
"Modified: / 24-08-2017 / 17:00:01 / cg" |
187 | 1382 |
! |
1383 |
||
1384 |
stringValue |
|
1385 |
"alias for #contents - for compatibility with ST-80's InputField" |
|
1386 |
||
1387 |
^ self contents |
|
1388 |
! ! |
|
1389 |
||
1390 |
!EditField methodsFor:'accessing-look'! |
|
125 | 1391 |
|
3585 | 1392 |
bePassword |
1393 |
"make me a password entry field (i.e. show *'s for typed characters" |
|
1394 |
||
1395 |
self passwordCharacter:$* |
|
1396 |
! |
|
1397 |
||
3990 | 1398 |
emptyFieldReplacementText |
3991 | 1399 |
"the string to show in grey if nothing has been entered (and the field is passive)" |
3990 | 1400 |
|
1401 |
^ emptyFieldReplacementText |
|
1402 |
! |
|
1403 |
||
1404 |
emptyFieldReplacementText:something |
|
3991 | 1405 |
"the string to show in grey if nothing has been entered (and the field is passive)" |
3990 | 1406 |
|
1407 |
emptyFieldReplacementText := something. |
|
1408 |
! |
|
1409 |
||
4989 | 1410 |
font:aFont |
1411 |
super font:aFont. |
|
5044 | 1412 |
realized ifTrue:[ self computeTopMargin ]. |
4989 | 1413 |
! |
1414 |
||
155 | 1415 |
maxChars |
1416 |
"return the maximum number of characters that are allowed in |
|
1417 |
the field. |
|
1418 |
A limit of nil means: unlimited. This is the default." |
|
1419 |
||
1420 |
^ lengthLimit |
|
1421 |
||
1422 |
"Modified: 6.9.1995 / 13:43:33 / claus" |
|
1423 |
! |
|
1424 |
||
125 | 1425 |
maxChars:aNumberOrNil |
1426 |
"set the maximum number of characters that are allowed in |
|
1427 |
the field. Additional input will be ignored by the field. |
|
1034 | 1428 |
A limit of nil or zero 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
|
1429 |
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
|
1430 |
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
|
1431 |
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
|
1432 |
|
125 | 1433 |
This method has been renamed from #lengthLimit: for ST-80 |
1434 |
compatibility." |
|
1435 |
||
1034 | 1436 |
aNumberOrNil == 0 ifTrue:[ |
1437 |
lengthLimit := nil |
|
1438 |
] ifFalse:[ |
|
1439 |
lengthLimit := aNumberOrNil. |
|
1440 |
] |
|
187 | 1441 |
! |
1442 |
||
192 | 1443 |
passwordCharacter |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1444 |
"return the passwordCharacter; |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1445 |
If nonNil, that one is replacing typed input |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1446 |
(for secret input)" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1447 |
|
192 | 1448 |
^ passwordCharacter |
0 | 1449 |
|
192 | 1450 |
"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
|
1451 |
"Modified: 16.12.1995 / 16:24:25 / cg" |
125 | 1452 |
! |
1453 |
||
192 | 1454 |
passwordCharacter:aCharacter |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1455 |
"set the passwordCharacter; |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1456 |
If nonNil, that one is replacing typed input |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1457 |
(for secret input)" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1458 |
|
192 | 1459 |
passwordCharacter := aCharacter |
97 | 1460 |
|
192 | 1461 |
"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
|
1462 |
"Modified: 16.12.1995 / 16:24:33 / cg" |
38 | 1463 |
! ! |
1464 |
||
1829 | 1465 |
!EditField methodsFor:'cursor drawing'! |
1466 |
||
1467 |
cursorShown:aBoolean |
|
1468 |
"make cursor visible if currently invisible - but only if this |
|
1880 | 1469 |
EditField is enabled. |
1470 |
Return the previous cursor-shown-state" |
|
1399 | 1471 |
|
1836 | 1472 |
^ super cursorShown:(aBoolean and:[enabled and:[self isReadOnly not]]) |
1399 | 1473 |
|
1829 | 1474 |
"Created: / 30.3.1999 / 16:00:25 / stefan" |
1880 | 1475 |
"Modified: / 1.4.1999 / 11:18:38 / cg" |
1829 | 1476 |
! |
0 | 1477 |
|
155 | 1478 |
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg |
1479 |
startVisLineNr to:endVisLineNr do:[:visLine | |
|
1480 |
self drawVisibleLine:visLine with:fg and:bg |
|
1481 |
] |
|
1482 |
||
1483 |
"Modified: 6.9.1995 / 12:24:29 / claus" |
|
0 | 1484 |
! ! |
1485 |
||
1486 |
!EditField methodsFor:'cursor movement'! |
|
1487 |
||
1488 |
cursorDown |
|
1489 |
"catch cursor movement" |
|
1490 |
||
1491 |
(cursorVisibleLine == nLinesShown) ifFalse:[ |
|
59 | 1492 |
super cursorDown |
0 | 1493 |
] |
192 | 1494 |
! |
1495 |
||
6222 | 1496 |
cursorLeft |
1497 |
super cursorLeft |
|
1498 |
||
1499 |
"Created: / 23-10-2017 / 18:28:38 / cg" |
|
1500 |
! |
|
1501 |
||
192 | 1502 |
cursorLine:line col:col |
1503 |
"catch cursor movement" |
|
1504 |
||
1505 |
super cursorLine:1 col:col |
|
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1506 |
! |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1507 |
|
5055 | 1508 |
cursorLine:line col:col makeVisible:aBoolean |
1509 |
"catch cursor movement" |
|
1510 |
||
1511 |
super cursorLine:1 col:col makeVisible:aBoolean |
|
1512 |
! |
|
1513 |
||
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1514 |
validateCursorCol:col inLine:line |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1515 |
"check of col is a valid cursor position; |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1516 |
return a fixed value if not." |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1517 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1518 |
|sz| |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1519 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1520 |
sz := self contents size. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1521 |
lengthLimit notNil ifTrue:[ |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1522 |
sz := sz min:lengthLimit. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1523 |
]. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1524 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1525 |
col <= sz ifTrue:[ |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1526 |
^ col |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1527 |
]. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1528 |
^ sz + 1. "/ to allow positioning right behind the string |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1529 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1530 |
"Created: 22.5.1996 / 18:17:27 / cg" |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1531 |
"Modified: 22.5.1996 / 18:19:04 / cg" |
192 | 1532 |
! ! |
1533 |
||
3413 | 1534 |
!EditField methodsFor:'drag & drop'! |
1535 |
||
1536 |
dropFileObject:aDropObject |
|
1537 |
"drop objects |
|
1538 |
Redefined to always drop the name only" |
|
1539 |
||
3797 | 1540 |
self |
4115 | 1541 |
undoablePasteReplacingAll:(aDropObject asFilename pathName) |
3797 | 1542 |
info:'Drop Filename'. |
3413 | 1543 |
|
1544 |
"Created: / 13-10-2006 / 17:42:22 / cg" |
|
3494 | 1545 |
"Modified: / 28-07-2007 / 13:27:32 / cg" |
3413 | 1546 |
! ! |
1547 |
||
192 | 1548 |
!EditField methodsFor:'editing'! |
1549 |
||
1550 |
paste:someText |
|
1551 |
"redefined to force text to 1 line" |
|
1552 |
||
1553 |
super paste:someText. |
|
1554 |
list size > 1 ifTrue:[ |
|
1555 |
self deleteFromLine:2 toLine:(list size) |
|
1556 |
] |
|
0 | 1557 |
! ! |
1558 |
||
70 | 1559 |
!EditField methodsFor:'event handling'! |
19 | 1560 |
|
192 | 1561 |
buttonPress:button x:x y:y |
1562 |
"enable myself on mouse click" |
|
1563 |
||
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1564 |
|prevFocus| |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1565 |
|
3703
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1566 |
enabled ifTrue:[ |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1567 |
prevFocus := hasKeyboardFocus. |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1568 |
clickAction notNil ifTrue:[ |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1569 |
clickAction value:self |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1570 |
]. |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1571 |
hasKeyboardFocus ~~ prevFocus ifTrue:[ |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1572 |
^ self |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1573 |
]. |
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1574 |
]. |
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1575 |
super buttonPress:button x:x y:y |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1576 |
|
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1577 |
"/ enabled ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1578 |
"/ enabled := true. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1579 |
"/ super buttonPress:button x:x y:y. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1580 |
"/ enableAction notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1581 |
"/ enableAction value |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1582 |
"/ ] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1583 |
"/ ] ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1584 |
"/ super buttonPress:button x:x y:y |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1585 |
"/ ] |
333 | 1586 |
|
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1587 |
"Modified: 22.5.1996 / 15:02:45 / cg" |
192 | 1588 |
! |
1589 |
||
6117 | 1590 |
buttonRelease:button x:x y:y |
1591 |
"if the selection is empty (because of validateSelection, |
|
1592 |
clear it alltogether, so that the cursor becomes visible again" |
|
1593 |
||
1594 |
(selectionStartCol notNil and:[selectionEndCol notNil |
|
1595 |
and:[ selectionStartLine == 1 and:[selectionEndLine == 1]]]) ifTrue:[ |
|
1596 |
selectionEndCol < selectionStartCol ifTrue:[ |
|
1597 |
selectionStartCol := selectionEndCol := nil. |
|
1598 |
selectionStartLine := selectionEndLine := nil. |
|
1599 |
] |
|
1600 |
]. |
|
1601 |
super buttonRelease:button x:x y:y |
|
1602 |
||
1603 |
"Created: / 07-03-2017 / 15:52:56 / cg" |
|
1604 |
! |
|
1605 |
||
192 | 1606 |
canHandle:aKey |
1607 |
"return true, if the receiver would like to handle aKey |
|
1608 |
(usually from another view, when the receiver is part of |
|
1609 |
a more complex dialog box). |
|
1610 |
We do return true here, since the editfield will handle |
|
1611 |
all keys. |
|
5594 | 1612 |
OBSOLETE: don't use this anymore - its a leftover for the tableWidget" |
192 | 1613 |
|
1614 |
^ true |
|
1615 |
! |
|
1616 |
||
3216 | 1617 |
doubleClickX:x y:y |
1618 |
doubleClickAction notNil ifTrue: [ |
|
1619 |
doubleClickAction value. |
|
1620 |
]. |
|
1621 |
||
1622 |
super doubleClickX:x y:y |
|
1623 |
! |
|
1624 |
||
4608 | 1625 |
handleCompletionService |
1626 |
"none here" |
|
1627 |
||
1628 |
^ self |
|
1629 |
! |
|
1630 |
||
3460 | 1631 |
handleFocusKey:key |
3535 | 1632 |
"handle a focus key, to assign the focus to another field in my group" |
1633 |
||
3460 | 1634 |
<resource: #keyboard (#Tab #Return #CursorDown #CursorUp)> |
1635 |
||
1636 |
windowGroup isNil ifTrue:[^ self ]. |
|
1637 |
||
1638 |
(key == #Tab) ifTrue:[ |
|
1639 |
(self tabRequiresControl not |
|
1640 |
or:[ self sensor ctrlDown ]) ifTrue:[ |
|
1641 |
self sensor shiftDown ifTrue:[ |
|
1642 |
windowGroup focusPrevious |
|
1643 |
] ifFalse:[ |
|
1644 |
windowGroup focusNext |
|
1645 |
]. |
|
1646 |
]. |
|
1647 |
^ self |
|
1648 |
]. |
|
1649 |
||
1650 |
(key == #Return) ifTrue:[ |
|
1651 |
windowGroup focusNext. |
|
1652 |
^ self |
|
1653 |
]. |
|
1654 |
||
1655 |
key == #CursorDown ifTrue:[ |
|
1656 |
windowGroup focusNext. |
|
1657 |
^ self. |
|
1658 |
]. |
|
1659 |
key == #CursorUp ifTrue:[ |
|
1660 |
windowGroup focusPrevious. |
|
1661 |
^ self. |
|
1662 |
]. |
|
1663 |
||
1664 |
"Created: / 06-03-2007 / 20:14:04 / cg" |
|
1665 |
! |
|
1666 |
||
125 | 1667 |
keyPress:key x:x y:y |
1668 |
"if keyHandler is defined, pass input; otherwise check for leave |
|
1669 |
keys" |
|
1670 |
||
490 | 1671 |
<resource: #keyboard (#Tab #Return #Find #FindNext #FindPrev |
922 | 1672 |
#DeleteLine #GotoLine #EndOfLine #EndOfText |
1673 |
#CursorDown #CursorUp)> |
|
132 | 1674 |
|
6389 | 1675 |
|rawKey leave doAccept keyAction numArgs| |
125 | 1676 |
|
1677 |
enabled ifFalse:[ |
|
325 | 1678 |
^ self |
125 | 1679 |
]. |
1680 |
||
1681 |
(key == #DeleteLine) ifTrue:[ |
|
325 | 1682 |
Smalltalk at:#CopyBuffer put:(self contents). |
3797 | 1683 |
self contents:''. |
1684 |
^ self |
|
125 | 1685 |
]. |
19 | 1686 |
|
3460 | 1687 |
(key == entryCompletionCharacter and:[self entryCompletionBlock notNil]) ifTrue:[ |
6305 | 1688 |
self doCompletion. |
979 | 1689 |
^ self |
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1690 |
]. |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1691 |
|
125 | 1692 |
(key == #Tab) ifTrue:[ |
3460 | 1693 |
doAccept := acceptOnTab. |
1694 |
keyAction := tabAction. |
|
1695 |
]. |
|
1696 |
(key == #Return) ifTrue:[ |
|
1697 |
doAccept := acceptOnReturn. |
|
1698 |
keyAction := crAction. |
|
1699 |
]. |
|
1700 |
||
6389 | 1701 |
rawKey := (WindowGroup lastEvent) rawKey. |
1702 |
||
1703 |
leave := (leaveKeys includes:key) or:[leaveKeys includes:rawKey]. |
|
3460 | 1704 |
leave ifTrue:[ |
1705 |
leaveKey := key. |
|
1706 |
doAccept := doAccept ? acceptOnLeave. |
|
4720 | 1707 |
|
1708 |
"/ on leave, the precedence of actions is: |
|
1709 |
"/ 1) explicit leaveAction per key |
|
1710 |
"/ 2) general leaveAction |
|
1711 |
"/ 3) tab or return action |
|
1712 |
leaveKeyActions notNil ifTrue:[ |
|
6389 | 1713 |
keyAction := leaveKeyActions |
1714 |
at:key |
|
1715 |
ifAbsent:[ |
|
1716 |
leaveKeyActions |
|
1717 |
at:rawKey |
|
1718 |
ifAbsent:keyAction]. |
|
4720 | 1719 |
]. |
3460 | 1720 |
keyAction := keyAction ? leaveAction. |
1721 |
]. |
|
1722 |
||
1723 |
doAccept == true ifTrue:[ |
|
1724 |
self accept. |
|
1725 |
]. |
|
1726 |
||
1727 |
keyAction notNil ifTrue:[ |
|
3462
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1728 |
numArgs := keyAction numArgs. |
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1729 |
|
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1730 |
numArgs == 2 ifTrue:[ |
3460 | 1731 |
^ keyAction value:self value:key |
964
73525cfd8fa2
dont forget to accept, when only (cr- and tab-) actions are defined
Claus Gittinger <cg@exept.de>
parents:
922
diff
changeset
|
1732 |
]. |
3462
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1733 |
numArgs == 0 ifTrue:[ |
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1734 |
^ keyAction value |
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1735 |
]. |
3460 | 1736 |
^ keyAction value:key |
125 | 1737 |
]. |
480 | 1738 |
|
125 | 1739 |
leave ifTrue:[ |
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1740 |
(x notNil and:[x >= 0]) ifTrue:[ |
325 | 1741 |
" |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1742 |
we do not handle this key directly. |
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1743 |
let superview know about the key that caused us to leave (maybe RETURN, DOWN, UP etc.... |
325 | 1744 |
" |
1745 |
(superView notNil and:[superView canHandle:key from:self]) ifTrue:[ |
|
1746 |
superView keyPress:key x:x y:y. |
|
1747 |
]. |
|
1748 |
]. |
|
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1749 |
|
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1750 |
"/ a leave, but no action defined |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1751 |
"/ forward it as a Focus-step |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1752 |
key == #CursorDown ifTrue:[ |
3460 | 1753 |
self handleFocusKey:key. |
2708
dfdf8977e9ba
care for nil windogroup (editor in dataSet)
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
1754 |
^ self. |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1755 |
]. |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1756 |
key == #CursorUp ifTrue:[ |
3460 | 1757 |
self handleFocusKey:key. |
2708
dfdf8977e9ba
care for nil windogroup (editor in dataSet)
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
1758 |
^ self. |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1759 |
]. |
325 | 1760 |
^ self |
19 | 1761 |
]. |
121 | 1762 |
|
125 | 1763 |
" |
1764 |
ignore some keys (if not a leaveKey) ... |
|
1765 |
" |
|
1766 |
(key == #Find) ifTrue:[^self]. |
|
1767 |
(key == #FindNext) ifTrue:[^self]. |
|
1768 |
(key == #FindPrev) ifTrue:[^self]. |
|
1769 |
(key == #GotoLine) ifTrue:[^self]. |
|
1770 |
" |
|
1771 |
a normal key - let superclass's method insert it |
|
1772 |
" |
|
1773 |
super keyPress:key x:x y:y. |
|
1774 |
||
1775 |
" |
|
1776 |
for end-of-text, also move to end-of-line |
|
1777 |
" |
|
1778 |
key == #EndOfText ifTrue:[ |
|
325 | 1779 |
super keyPress:#EndOfLine x:x y:y. |
125 | 1780 |
]. |
6136 | 1781 |
|
1782 |
key isCharacter ifTrue:[ |
|
1783 |
self resizeOrScroll. |
|
1784 |
]. |
|
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1785 |
|
6209 | 1786 |
"Modified: / 27-09-2017 / 15:34:19 / cg" |
6305 | 1787 |
"Modified: / 18-04-2018 / 11:47:58 / stefan" |
6389 | 1788 |
"Modified: / 09-08-2018 / 09:29:52 / Claus Gittinger" |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1789 |
! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1790 |
|
6253 | 1791 |
keyboardZoom:largerBoolean |
6254 | 1792 |
"CTRL+/- zoom action" |
1793 |
||
5929 | 1794 |
"/ ignored here |
1795 |
! |
|
1796 |
||
1936 | 1797 |
pointerLeave:state |
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
1798 |
(acceptOnPointerLeave and:[enabled and:[self modified]]) ifTrue:[ |
1936 | 1799 |
self accept |
1800 |
]. |
|
1801 |
super pointerLeave:state |
|
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
1802 |
|
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
1803 |
"Modified: / 28.6.1999 / 18:08:29 / cg" |
1936 | 1804 |
! |
1805 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1806 |
resizeOrScroll |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1807 |
"helper for keyPress. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1808 |
Extracted for easier subclass redefinition." |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1809 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1810 |
|xCol newOffset newWidth| |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1811 |
|
125 | 1812 |
newWidth := self widthOfContents. |
1813 |
||
1814 |
" |
|
1815 |
should (& can) we resize ? |
|
1816 |
" |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1817 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - viewOrigin x. |
6139 | 1818 |
(xCol > (width - 50 "* (5/6)")) ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1819 |
self changedPreferredBounds:nil |
125 | 1820 |
] ifFalse:[ |
6139 | 1821 |
"/ Do not shrink!! Enterbox grows if size of contained Editfield changes!! |
1822 |
"/ newWidth < (width * (1/3)) ifTrue:[ |
|
1823 |
"/ self changedPreferredBounds:nil |
|
1824 |
"/ ] |
|
125 | 1825 |
]. |
1826 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1827 |
autoScrollHorizontally ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1828 |
" |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1829 |
did someone react (i.e. has my extent changed) ? |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1830 |
(if not, we scroll horizontally) |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1831 |
" |
2016
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1832 |
lengthLimit notNil ifTrue:[ |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1833 |
(self xOfCol:lengthLimit+1 inVisibleLine:cursorLine) <= self innerWidth |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1834 |
ifTrue:[ |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1835 |
^ self |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1836 |
]. |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1837 |
]. |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1838 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1839 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - viewOrigin x. |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1840 |
(xCol > (width * (5/6))) ifTrue:[ |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1841 |
newOffset := viewOrigin x + (width // 2). |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1842 |
] ifFalse:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1843 |
(xCol < (width * (1/6))) ifTrue:[ |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1844 |
newOffset := 0 max: viewOrigin x - (width // 2). |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1845 |
] ifFalse:[ |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1846 |
newOffset := viewOrigin x |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1847 |
] |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1848 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1849 |
newOffset ~~ viewOrigin x ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1850 |
self scrollHorizontalTo:newOffset. |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1851 |
] |
125 | 1852 |
]. |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1853 |
|
6136 | 1854 |
"Modified: / 15-03-2017 / 19:22:56 / cg" |
6139 | 1855 |
"Modified: / 30-03-2017 / 18:46:50 / stefan" |
1856 |
"Modified (format): / 30-03-2017 / 22:24:58 / stefan" |
|
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1857 |
! |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1858 |
|
784
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1859 |
sizeChanged:how |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1860 |
"scroll to origin, if all fits" |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1861 |
|
1282 | 1862 |
|xCol| |
784
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1863 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1864 |
viewOrigin x ~~ 0 ifTrue:[ |
784
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1865 |
xCol := self xOfCol:cursorCol inVisibleLine:cursorLine. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1866 |
(xCol < (width * (5/6))) ifTrue:[ |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1867 |
self scrollHorizontalTo:0 |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1868 |
]. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1869 |
]. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1870 |
self makeCursorVisible. |
4989 | 1871 |
super sizeChanged:how. |
1872 |
self computeTopMargin. |
|
784
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1873 |
|
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1874 |
"Modified: 10.7.1996 / 10:59:37 / cg" |
4986
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1875 |
! |
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1876 |
|
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1877 |
tripleClickX:x y:y |
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1878 |
"triple-click - select all" |
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1879 |
|
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1880 |
self selectAll |
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1881 |
|
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1882 |
"Created: / 09-04-2014 / 19:04:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
192 | 1883 |
! ! |
1884 |
||
1806 | 1885 |
!EditField methodsFor:'focus handling'! |
1886 |
||
1887 |
hasKeyboardFocus:aBoolean |
|
1888 |
"the view got/lost the keyboard focus" |
|
1889 |
||
4930 | 1890 |
|hadKeyboardFocus| |
1891 |
||
1892 |
hadKeyboardFocus := hasKeyboardFocus. |
|
1893 |
super hasKeyboardFocus:aBoolean. |
|
1894 |
||
1895 |
(acceptOnLostFocus and:[enabled and:[aBoolean not and:[hadKeyboardFocus]]]) ifTrue:[ |
|
6113 | 1896 |
(model notNil and:[model value = self argForChangeMessage]) ifTrue:[ |
1897 |
^ self |
|
1806 | 1898 |
]. |
4930 | 1899 |
self accept. |
1806 | 1900 |
]. |
1901 |
||
1902 |
"Created: / 11.12.1996 / 16:57:50 / cg" |
|
1903 |
"Modified: / 6.12.1997 / 14:07:12 / cg" |
|
1904 |
! |
|
1905 |
||
1906 |
showFocus:explicit |
|
1907 |
"the view got the keyboard focus |
|
1908 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
1909 |
- change any display attributes as req'd." |
|
1910 |
||
1911 |
"/ giving me the focus is like clicking on me |
|
1912 |
"/ (tell my enterFieldGroup ...) |
|
1913 |
||
1914 |
||
1915 |
(enabled or:[explicit]) ifTrue:[ |
|
5240 | 1916 |
super showFocus:explicit. |
1806 | 1917 |
clickAction notNil ifTrue:[clickAction value:self]. |
3461 | 1918 |
"/ mhmh - should we ALWAYS do this ? |
5240 | 1919 |
true "explicit" ifTrue:[ self makeCursorVisible ]. |
1806 | 1920 |
] |
1921 |
||
3461 | 1922 |
"Modified: / 06-03-2007 / 21:11:17 / cg" |
1806 | 1923 |
! |
1924 |
||
1925 |
showNoFocus:explicit |
|
1926 |
"the view lost the keyboard focus |
|
1927 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
1928 |
- change any display attributes as req'd." |
|
1929 |
||
1930 |
self hideCursor. |
|
1931 |
super showNoFocus:explicit |
|
1932 |
||
1933 |
"Modified: / 17.9.1998 / 15:10:04 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1934 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1935 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1936 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1937 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1938 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1939 |
|
4992 | 1940 |
^ UserPreferences current focusFollowsMouse ~~ false |
1941 |
and:[(styleSheet at:#'editField.requestFocusOnPointerEnter' default:true) |
|
1942 |
and:[self enabled |
|
1943 |
and:[self isReadOnly not]]] |
|
1806 | 1944 |
! ! |
1945 |
||
5484 | 1946 |
!EditField methodsFor:'help'! |
1947 |
||
6255 | 1948 |
helpTextAt:aPoint |
5484 | 1949 |
|len| |
1950 |
||
1951 |
len := self widthOfContents. |
|
1952 |
len > width ifTrue:[ |
|
1953 |
^ self contents |
|
1954 |
]. |
|
1955 |
^ nil |
|
1956 |
! ! |
|
1957 |
||
2750 | 1958 |
!EditField methodsFor:'initialization & release'! |
192 | 1959 |
|
4989 | 1960 |
computeTopMargin |
5043 | 1961 |
|innerHeight rest font fontHeight fontDescent| |
4989 | 1962 |
|
1963 |
innerHeight := self innerHeight. |
|
5044 | 1964 |
innerHeight <= 0 ifTrue:[ textStartTop := 0. ^ self ]. |
1965 |
||
5043 | 1966 |
font := gc font. |
1967 |
fontHeight := font height. |
|
1968 |
fontDescent := font descent. |
|
1969 |
rest := innerHeight - (fontHeight + (fontDescent // 2)). |
|
4989 | 1970 |
rest > 1 ifTrue:[ |
1971 |
textStartTop := (rest // 2) + margin + topMargin |
|
5043 | 1972 |
] ifFalse:[ |
1973 |
"/ care if font is too high for my height: |
|
1974 |
"/ shift baseline towards the top, so that the same is cut off at both ends. |
|
1975 |
"/ (the heuristic fontDescent//3) gives a few pixels more at the top) |
|
5044 | 1976 |
textStartTop := 1 "(fontDescent//3)" - ((font ascent + fontDescent - innerHeight) // 2). |
1977 |
]. |
|
4989 | 1978 |
! |
1979 |
||
192 | 1980 |
initStyle |
967 | 1981 |
"setup viewStyle specifics" |
1982 |
||
3265 | 1983 |
<resource: #style (#'editField.cursorType' |
1984 |
#'editField.cursorForegroundColor' |
|
4013 | 1985 |
#'editField.cursorBackgroundColor' |
3265 | 1986 |
)> |
1987 |
||
192 | 1988 |
super initStyle. |
1989 |
||
4989 | 1990 |
self computeTopMargin. |
1991 |
||
192 | 1992 |
DefaultBackgroundColor notNil ifTrue:[ |
5642 | 1993 |
bgColor := DefaultBackgroundColor onDevice:device. |
1482 | 1994 |
"/ bgColor ditherForm notNil ifTrue:[ |
4896 | 1995 |
"/ bgColor := (bgColor copy) exactOrNearestOn:self graphicsDevice |
1482 | 1996 |
"/ ]. |
967 | 1997 |
self viewBackground:bgColor. |
192 | 1998 |
]. |
1999 |
fgColor := DefaultForegroundColor. |
|
2000 |
selectionFgColor := DefaultSelectionForegroundColor. |
|
2001 |
selectionBgColor := DefaultSelectionBackgroundColor. |
|
967 | 2002 |
|
1544
bb7e168dd651
dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents:
1542
diff
changeset
|
2003 |
"/ enable this, when the focus detection works correctly (in dialogs) |
1848 | 2004 |
cursorTypeNoFocus := #none. |
2005 |
||
2006 |
cursorType := styleSheet at:#'editField.cursorType' default:cursorType. |
|
2007 |
||
2008 |
cursorFgColor := styleSheet at:#'editField.cursorForegroundColor' default:cursorFgColor. |
|
2009 |
cursorBgColor := styleSheet at:#'editField.cursorBackgroundColor' default:cursorBgColor. |
|
1544
bb7e168dd651
dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents:
1542
diff
changeset
|
2010 |
|
4013 | 2011 |
DefaultLevel notNil ifTrue:[ |
2012 |
self level:DefaultLevel. |
|
2013 |
]. |
|
2014 |
DefaultBorderWidth notNil ifTrue:[ |
|
2015 |
self borderWidth:DefaultBorderWidth. |
|
2016 |
DefaultBorderColor notNil ifTrue:[ |
|
2017 |
self borderColor:DefaultBorderColor. |
|
2018 |
]. |
|
2019 |
]. |
|
2020 |
||
4320 | 2021 |
"Modified: / 21-05-1998 / 15:38:14 / cg" |
2022 |
"Modified (comment): / 05-10-2011 / 15:51:15 / az" |
|
192 | 2023 |
! |
0 | 2024 |
|
192 | 2025 |
initialize |
5910 | 2026 |
|font| |
2027 |
||
192 | 2028 |
super initialize. |
5910 | 2029 |
font := gc font. |
2030 |
self initialHeight:(font height + font descent + (topMargin * 2)). |
|
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
2031 |
|
192 | 2032 |
nFullLinesShown := 1. |
2033 |
nLinesShown := 1. |
|
1225
6220d3bd3033
initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
2034 |
trimBlankLines := immediateAccept := acceptOnLostFocus := false. |
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
2035 |
acceptOnPointerLeave := false. |
1225
6220d3bd3033
initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
2036 |
enabled := fixedSize := autoScrollHorizontally := true. |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
2037 |
acceptOnLeave := acceptOnReturn := acceptOnTab := true. |
192 | 2038 |
cursorShown := true. |
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
2039 |
entryCompletionCharacter := #Tab. |
2105 | 2040 |
acceptIfUnchanged := false. |
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
2041 |
|
594 | 2042 |
leaveKeys isNil ifTrue:[ |
2043 |
leaveKeys := self class defaultLeaveKeys. |
|
2044 |
]. |
|
192 | 2045 |
cursorMovementWhenUpdating := #endOfLine |
594 | 2046 |
|
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
2047 |
"Modified: / 28.6.1999 / 18:08:17 / cg" |
192 | 2048 |
! ! |
2049 |
||
3702 | 2050 |
!EditField methodsFor:'menu actions'! |
2051 |
||
2052 |
editMenu |
|
2053 |
"return a popUpMenu for the receiver" |
|
2054 |
||
2055 |
<resource: #keyboard ( #Accept #Copy #Cut #Paste ) > |
|
2056 |
<resource: #programMenu> |
|
2057 |
||
4212 | 2058 |
|items m isReadOnly| |
2059 |
||
2060 |
isReadOnly := (self isReadOnly == true or:[enabled == false]). |
|
2061 |
isReadOnly ifTrue:[ |
|
3702 | 2062 |
items := #( |
2063 |
('Copy' copySelection Copy ) |
|
2064 |
) |
|
2065 |
] ifFalse:[ |
|
2066 |
items := #( |
|
2067 |
('Cut' cut Cut ) |
|
2068 |
('Copy' copySelection Copy ) |
|
2069 |
('Paste' pasteOrReplace Paste ) |
|
2070 |
). |
|
2071 |
(acceptAction notNil |
|
2072 |
or:[model notNil and:[changeMsg notNil]]) ifTrue:[ |
|
2073 |
immediateAccept ifFalse:[ |
|
2074 |
items := items , #( |
|
2075 |
('-' ) |
|
2076 |
('Accept' accept Accept) |
|
2077 |
). |
|
2078 |
]. |
|
2079 |
]. |
|
2080 |
]. |
|
2081 |
||
6190 | 2082 |
passwordCharacter notNil ifTrue:[ |
2083 |
items := items , |
|
2084 |
#( |
|
2085 |
('-' ) |
|
2086 |
('Show Password' showPasswordCharacters ) |
|
2087 |
). |
|
2088 |
] ifFalse:[ |
|
2089 |
items := items , |
|
2090 |
#( |
|
2091 |
('-' ) |
|
2092 |
('Hide as Password' hideAsPassword ) |
|
2093 |
). |
|
2094 |
]. |
|
2095 |
||
4992 | 2096 |
isReadOnly ifFalse:[ |
4194 | 2097 |
items := items , |
2098 |
#( |
|
2099 |
('-' ) |
|
4938 | 2100 |
('Insert Unicode...' insertUnicode ) |
4194 | 2101 |
). |
4938 | 2102 |
CharacterSetView notNil ifTrue:[ |
2103 |
items := items , |
|
2104 |
#( |
|
2105 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
2106 |
). |
|
2107 |
]. |
|
4194 | 2108 |
]. |
2109 |
||
3702 | 2110 |
m := PopUpMenu itemList:items resources:resources. |
2111 |
||
2112 |
passwordCharacter notNil ifTrue:[ |
|
2113 |
m disable:#copySelection |
|
2114 |
]. |
|
2115 |
||
2116 |
self hasSelectionForCopy ifFalse:[ |
|
2117 |
m disable:#copySelection |
|
2118 |
]. |
|
2119 |
self hasSelection ifFalse:[ |
|
2120 |
m disable:#cut |
|
2121 |
]. |
|
4212 | 2122 |
isReadOnly ifTrue:[ |
3702 | 2123 |
m disableAll:#(cut pasteOrReplace accept) |
2124 |
]. |
|
2125 |
||
2126 |
^ m |
|
2127 |
||
6190 | 2128 |
"Modified: / 17-08-2017 / 00:11:36 / cg" |
2129 |
! |
|
2130 |
||
2131 |
hideAsPassword |
|
2132 |
passwordCharacter := $*. |
|
2133 |
self invalidate |
|
2134 |
||
2135 |
"Created: / 17-08-2017 / 00:11:41 / cg" |
|
2136 |
! |
|
2137 |
||
2138 |
showPasswordCharacters |
|
2139 |
passwordCharacter := nil. |
|
2140 |
self invalidate |
|
2141 |
||
2142 |
"Created: / 17-08-2017 / 00:11:27 / cg" |
|
3702 | 2143 |
! ! |
2144 |
||
5122 | 2145 |
!EditField methodsFor:'native widget support'! |
2146 |
||
2147 |
nativeWindowType |
|
2148 |
"return a symbol describing my native window type |
|
5542 | 2149 |
(may be used internally by the device as a native window creation hint, |
2150 |
if the device supports native windows)" |
|
5122 | 2151 |
|
2152 |
^ #EditField |
|
2153 |
! ! |
|
2154 |
||
192 | 2155 |
!EditField methodsFor:'private'! |
2156 |
||
2157 |
argForChangeMessage |
|
2158 |
"redefined to send use converted value (if I have one)" |
|
2159 |
||
2538
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2160 |
|str| |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2161 |
|
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2162 |
str := self editValue. |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2163 |
(acceptIfUnchanged |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2164 |
and:[model notNil |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2165 |
and:[model value == self editValue]]) ifTrue:[ |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2166 |
"/ copy to force valueHolder to trigger |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2167 |
str := str copy. |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2168 |
]. |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2169 |
^ str |
192 | 2170 |
! |
2171 |
||
6305 | 2172 |
doCompletion |
2173 |
|oldContents newContents| |
|
2174 |
||
2175 |
self entryCompletionBlock isNil ifTrue:[ |
|
2176 |
^ self. |
|
2177 |
]. |
|
2178 |
||
2179 |
oldContents := self contents. |
|
2180 |
oldContents isNil ifTrue:[ |
|
2181 |
oldContents := '' |
|
2182 |
] ifFalse:[ |
|
2183 |
oldContents := oldContents asString |
|
2184 |
]. |
|
2185 |
||
2186 |
self entryCompletionBlock valueWithOptionalArgument:oldContents and:self. |
|
2187 |
||
2188 |
newContents := self contents. |
|
2189 |
newContents isNil ifTrue:[ |
|
2190 |
newContents := '' |
|
2191 |
] ifFalse:[ |
|
2192 |
newContents := newContents asString |
|
2193 |
]. |
|
2194 |
newContents ~= oldContents ifTrue:[ |
|
2195 |
self textChanged |
|
2196 |
]. |
|
2197 |
||
2198 |
"Created: / 18-04-2018 / 11:46:17 / stefan" |
|
2199 |
! |
|
2200 |
||
192 | 2201 |
getListFromModel |
5777 | 2202 |
"redefined to acquire the text via the aspectMsg - not the listMsg, |
192 | 2203 |
and to ignore updates resulting from my own change." |
2204 |
||
1464 | 2205 |
|val| |
2206 |
||
192 | 2207 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
1464 | 2208 |
aspectMsg == #value ifTrue:[ |
2209 |
val := model value |
|
2210 |
] ifFalse:[ |
|
2211 |
val := model perform:aspectMsg |
|
2212 |
]. |
|
1503
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2213 |
|
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2214 |
" |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2215 |
ignore updates from my own change |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2216 |
" |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2217 |
lockUpdates ifTrue:[ |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2218 |
lockUpdates := false. |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2219 |
val = self editValue ifTrue:[ |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2220 |
^ self |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2221 |
] |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2222 |
]. |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2223 |
|
1464 | 2224 |
self editValue:val. |
0 | 2225 |
] |
1464 | 2226 |
|
1503
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2227 |
"Modified: / 23.4.1998 / 10:10:37 / cg" |
0 | 2228 |
! |
2229 |
||
192 | 2230 |
startAutoScrollDown:y |
2231 |
"no vertical scrolling in editfields" |
|
2232 |
||
5095 | 2233 |
^ false |
192 | 2234 |
! |
2235 |
||
2236 |
startAutoScrollUp:y |
|
2237 |
"no vertical scrolling in editfields" |
|
2238 |
||
5095 | 2239 |
^ false |
192 | 2240 |
! |
0 | 2241 |
|
192 | 2242 |
textChanged |
2243 |
"this is sent by mySelf (somewhere in a superclass) whenever |
|
2244 |
my contents has changed. |
|
2245 |
A good place to add immediateAccept functionality and check for the |
|
2246 |
lengthLimit." |
|
2247 |
||
2248 |
|string c| |
|
2249 |
||
2250 |
super textChanged. |
|
2251 |
string := self contents. |
|
2252 |
lengthLimit notNil ifTrue:[ |
|
2253 |
string size > lengthLimit ifTrue:[ |
|
2254 |
c := cursorCol. |
|
2255 |
self contents:(string copyTo:lengthLimit). |
|
2256 |
self flash. |
|
2257 |
self cursorCol:c. |
|
125 | 2258 |
] |
0 | 2259 |
]. |
192 | 2260 |
immediateAccept ifTrue:[ |
2261 |
self accept |
|
2262 |
] |
|
105 | 2263 |
! |
2264 |
||
2616 | 2265 |
textChangedButNoSizeChange |
2296
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2266 |
"this is sent by mySelf (somewhere in a superclass) whenever |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2267 |
my contents has changed. |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2268 |
A good place to add immediateAccept functionality." |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2269 |
|
2616 | 2270 |
super textChangedButNoSizeChange. |
2296
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2271 |
immediateAccept ifTrue:[ |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2272 |
self accept |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2273 |
] |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2274 |
! |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2275 |
|
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2276 |
updateBackground |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2277 |
"make my background grey, whenever either readOnly or disable" |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2278 |
|
1974 | 2279 |
|fg| |
2280 |
||
3648
7a959d9db34f
dont (re)set the background, if I have a bg-channel.
Claus Gittinger <cg@exept.de>
parents:
3585
diff
changeset
|
2281 |
backgroundChannel notNil ifTrue:[^ self]. |
7a959d9db34f
dont (re)set the background, if I have a bg-channel.
Claus Gittinger <cg@exept.de>
parents:
3585
diff
changeset
|
2282 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
2283 |
(self isReadOnly or:[enabled not]) ifTrue:[ |
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2284 |
self backgroundColor:(View defaultViewBackgroundColor). |
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2285 |
enabled ifFalse:[ |
1974 | 2286 |
fg := StyleSheet colorAt:'editField.disabledForegroundColor' default:nil. |
2287 |
fg isNil ifTrue:[ |
|
2288 |
fg := StyleSheet colorAt:'button.disabledForegroundColor' default:Color gray. |
|
2289 |
]. |
|
2290 |
self foregroundColor:fg. |
|
3408 | 2291 |
] ifTrue:[ |
2292 |
self foregroundColor:DefaultForegroundColor. |
|
2293 |
]. |
|
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2294 |
] ifFalse:[ |
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2295 |
self backgroundColor:DefaultBackgroundColor. |
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2296 |
self foregroundColor:DefaultForegroundColor. |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2297 |
] |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2298 |
|
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2299 |
"Modified: / 3.8.1998 / 18:40:11 / cg" |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2300 |
! |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2301 |
|
192 | 2302 |
visibleAt:visLineNr |
2303 |
"return the string at lineNr for display. |
|
2304 |
If there is a password character, return a string consisting of those only." |
|
2305 |
||
3988 | 2306 |
|s emptyText| |
105 | 2307 |
|
192 | 2308 |
s := super visibleAt:visLineNr. |
2309 |
passwordCharacter notNil ifTrue:[ |
|
3985 | 2310 |
^ String new:(s size) withAll:passwordCharacter |
192 | 2311 |
]. |
3985 | 2312 |
(s isEmptyOrNil |
3988 | 2313 |
and:[ (emptyText := self emptyFieldReplacementText) notNil |
3985 | 2314 |
and:[ self hasFocus not |
2315 |
and:[ visLineNr == 1 ]]]) |
|
2316 |
ifTrue:[ |
|
5725 | 2317 |
^ emptyText allItalic withColor:Color lightGray. |
3985 | 2318 |
]. |
2319 |
||
192 | 2320 |
^ s |
2321 |
||
2322 |
"Modified: 6.9.1995 / 12:25:06 / claus" |
|
0 | 2323 |
! ! |
125 | 2324 |
|
192 | 2325 |
!EditField methodsFor:'queries'! |
2326 |
||
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2349
diff
changeset
|
2327 |
hasSelectionForCopy |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2349
diff
changeset
|
2328 |
"return true, if there is a selection which can be copied." |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2349
diff
changeset
|
2329 |
|
4992 | 2330 |
^ passwordCharacter isNil and:[self hasSelection] |
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2349
diff
changeset
|
2331 |
! |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2349
diff
changeset
|
2332 |
|
561 | 2333 |
isInputField |
2334 |
"return true, if the receiver is some kind of input view, |
|
2335 |
i.e. it should (can) be part of an enterGroup. |
|
2336 |
Return true here" |
|
2337 |
||
2338 |
^ true |
|
2339 |
||
2340 |
"Created: 4.3.1996 / 11:32:34 / cg" |
|
2341 |
! |
|
2342 |
||
192 | 2343 |
preferredExtent |
2344 |
"return the preferred extent of this view. |
|
2345 |
That is the width of the string plus some extra, |
|
2346 |
but not wider than half of the screen" |
|
2347 |
||
1120 | 2348 |
|string w h f| |
125 | 2349 |
|
3768
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2350 |
"/ If I have an explicit preferredExtent.. |
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2351 |
explicitExtent notNil ifTrue:[ |
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2352 |
^ explicitExtent |
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2353 |
]. |
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2354 |
|
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2355 |
"/ If I have a cached preferredExtent value.. |
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
2356 |
preferredExtent notNil ifTrue:[ |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
2357 |
^ preferredExtent |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
2358 |
]. |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
2359 |
|
192 | 2360 |
string := self contents. |
2361 |
(string isNil or:[string isBlank]) ifTrue:[ |
|
4086 | 2362 |
w := fontWidth * 20. "space for 20 characters" |
2363 |
] ifFalse:[ |
|
2364 |
"length of current contents + 50% space to type more characters" |
|
5815 | 2365 |
f := gc deviceFont. |
4086 | 2366 |
w := ((f widthOf:string) * 1.5) rounded. |
2367 |
w := w + margin + margin. |
|
192 | 2368 |
]. |
6136 | 2369 |
"/ never more than the screen width, minus some |
2370 |
w := w min:(device width - 200 " // 2"). |
|
667
d02f6bba8fc5
use fonts maxHeight in prefExtent (A-Umlaut)
Claus Gittinger <cg@exept.de>
parents:
660
diff
changeset
|
2371 |
|
3929 | 2372 |
"/ h := f maxHeight + (f maxDescent * 2) + (margin * 2). |
4086 | 2373 |
h := fontHeight + topMargin + (margin * 2). |
1120 | 2374 |
|
2375 |
^ w rounded @ h rounded |
|
192 | 2376 |
|
6136 | 2377 |
"Modified: / 06-09-1995 / 19:24:06 / claus" |
2378 |
"Modified: / 15-03-2017 / 19:31:54 / cg" |
|
192 | 2379 |
! |
2380 |
||
2381 |
specClass |
|
1372 | 2382 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditFieldSpec)" |
2383 |
||
192 | 2384 |
self class == EditField ifTrue:[^ InputFieldSpec]. |
1047 | 2385 |
^ super specClass |
125 | 2386 |
|
1372 | 2387 |
"Modified: / 5.9.1995 / 17:28:27 / claus" |
2388 |
"Modified: / 31.10.1997 / 19:48:59 / cg" |
|
325 | 2389 |
! |
2390 |
||
2391 |
tabMeansNextField |
|
2392 |
"return true, if Tab character should shift focus to the next field" |
|
2393 |
||
2394 |
"if I have a completionBlock, I want my Tabs ..." |
|
2395 |
||
2993 | 2396 |
^ self entryCompletionBlock isNil or:[entryCompletionCharacter ~~ #Tab] |
325 | 2397 |
|
2398 |
"Created: 7.2.1996 / 19:16:38 / cg" |
|
192 | 2399 |
! ! |
2400 |
||
2401 |
!EditField methodsFor:'realization'! |
|
2402 |
||
1274 | 2403 |
realize |
192 | 2404 |
"scroll back to beginning when realized" |
1268 | 2405 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
2406 |
viewOrigin := 0 @ viewOrigin y. |
1274 | 2407 |
super realize |
1268 | 2408 |
|
1274 | 2409 |
"Created: 24.7.1997 / 18:23:15 / cg" |
125 | 2410 |
! ! |
192 | 2411 |
|
2412 |
!EditField methodsFor:'scrolling'! |
|
2413 |
||
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2414 |
makeColVisible:col inLine:lineNr |
6095 | 2415 |
"don't scroll for the cursor, if it's beyond the text and a lengthLimit |
192 | 2416 |
is present." |
2417 |
||
2759 | 2418 |
|wText innerWidth colToMakeVisible| |
2424 | 2419 |
|
2420 |
innerWidth := self innerWidth. |
|
2759 | 2421 |
colToMakeVisible := col. |
2016
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2422 |
|
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2423 |
lengthLimit notNil ifTrue:[ |
6222 | 2424 |
(self xOfCol:col-1 inVisibleLine:1) < self viewOrigin x ifTrue:[ |
2425 |
] ifFalse:[ |
|
2426 |
(self xOfCol:lengthLimit inVisibleLine:1) <= innerWidth |
|
2427 |
ifTrue:[ |
|
2428 |
^ self |
|
2429 |
]. |
|
2430 |
(self xOfCol:col inVisibleLine:1) <= innerWidth |
|
2431 |
ifTrue:[ |
|
2432 |
^ self |
|
2433 |
]. |
|
2434 |
(col == cursorCol and:[col > lengthLimit]) ifTrue:[ |
|
2435 |
colToMakeVisible := lengthLimit |
|
2436 |
]. |
|
2016
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2437 |
]. |
192 | 2438 |
]. |
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2439 |
|
2759 | 2440 |
super makeColVisible:colToMakeVisible inLine:lineNr. |
2441 |
||
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2442 |
"/ new: |
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2443 |
"/ care to make the most possible visible |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
2444 |
viewOrigin x > 0 ifTrue:[ |
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2445 |
wText := self widthOfLine:lineNr. |
6209 | 2446 |
wText < (innerWidth-10) ifTrue:[ |
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2447 |
self scrollHorizontalTo:0 |
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2448 |
] |
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2449 |
] |
192 | 2450 |
|
4157
7f2928f99268
comment/format in: #makeColVisible:inLine:
Claus Gittinger <cg@exept.de>
parents:
4118
diff
changeset
|
2451 |
"Modified: / 06-09-1995 / 13:57:53 / claus" |
6222 | 2452 |
"Modified: / 23-10-2017 / 18:32:34 / cg" |
192 | 2453 |
! ! |
2454 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2455 |
!EditField methodsFor:'selections'! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2456 |
|
3366
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2457 |
copySelection |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2458 |
"refuse to copy a password to the clipboard" |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2459 |
|
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2460 |
passwordCharacter notNil ifTrue:[ |
6268 | 2461 |
self beepInEditor. |
3366
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2462 |
^ self |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2463 |
]. |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2464 |
^ super copySelection |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2465 |
! |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2466 |
|
1080
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2467 |
selectAll |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2468 |
"select the whole text. |
5594 | 2469 |
redefined to send super selectFrom... since we don't want the |
1080
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2470 |
cursor to be moved in this case." |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2471 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2472 |
|len| |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2473 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2474 |
list isNil ifTrue:[ |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2475 |
self unselect |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2476 |
] ifFalse:[ |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2477 |
len := (self listAt:1) size. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2478 |
len ~~ 0 ifTrue:[ |
4992 | 2479 |
self selectFromLine:1 col:1 toLine:1 col:len. |
1080
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2480 |
]. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2481 |
typeOfSelection := nil |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2482 |
] |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2483 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2484 |
"Modified: 28.2.1997 / 19:16:21 / cg" |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2485 |
! |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2486 |
|
4540 | 2487 |
selectFrom:firstColToSelect |
2488 |
"select the right part of the text" |
|
2489 |
||
2490 |
|len| |
|
2491 |
||
2492 |
list isNil ifTrue:[ |
|
2493 |
self unselect |
|
2494 |
] ifFalse:[ |
|
2495 |
len := (self listAt:1) size. |
|
2496 |
firstColToSelect <= len ifTrue:[ |
|
2497 |
self selectFromLine:1 col:firstColToSelect toLine:1 col:len. |
|
2498 |
]. |
|
2499 |
typeOfSelection := nil |
|
2500 |
] |
|
2501 |
! |
|
2502 |
||
5973 | 2503 |
setClipboardText:aString |
5041 | 2504 |
"redefined to refuse to copy the password to the clipboard" |
2505 |
||
2506 |
passwordCharacter notNil ifTrue:[ |
|
6268 | 2507 |
self beepInEditor. |
5041 | 2508 |
^ self |
2509 |
]. |
|
5973 | 2510 |
^ super setClipboardText:aString |
2511 |
||
2512 |
"Modified (format): / 21-11-2016 / 23:37:07 / cg" |
|
5041 | 2513 |
! |
2514 |
||
5042 | 2515 |
setLastStringToReplace: sel |
2516 |
"redefined to refuse to remember the password" |
|
2517 |
||
2518 |
passwordCharacter notNil ifTrue:[ |
|
2519 |
^ self |
|
2520 |
]. |
|
2521 |
^ super setLastStringToReplace: sel |
|
2522 |
! |
|
2523 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2524 |
validateNewSelection |
6116 | 2525 |
"make certain that only one line is ever selected; |
2526 |
also check that the selection is within the string" |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2527 |
|
1654 | 2528 |
selectionEndLine notNil ifTrue:[ |
2529 |
selectionEndLine > 1 ifTrue:[ |
|
2530 |
selectionEndLine := 2. selectionEndCol := 0 |
|
2531 |
] |
|
2532 |
]. |
|
6116 | 2533 |
"/ new: 7.3.2017 |
2534 |
selectionStartCol notNil ifTrue:[ |
|
2535 |
selectionStartCol > (self contents size + 1) ifTrue:[ |
|
2536 |
selectionStartCol := self contents size + 1. |
|
2537 |
]. |
|
2538 |
selectionEndCol notNil ifTrue:[ |
|
2539 |
selectionEndCol > (self contents size) ifTrue:[ |
|
2540 |
selectionEndCol := self contents size. |
|
2541 |
]. |
|
2542 |
]. |
|
2543 |
]. |
|
2544 |
||
2545 |
"Modified (comment): / 07-03-2017 / 15:46:01 / cg" |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2546 |
! ! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2547 |
|
892 | 2548 |
!EditField class methodsFor:'documentation'! |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2549 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2550 |
version |
5484 | 2551 |
^ '$Header$' |
3975
73674d16fc63
copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
2552 |
! |
73674d16fc63
copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
2553 |
|
73674d16fc63
copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
2554 |
version_CVS |
5484 | 2555 |
^ '$Header$' |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2556 |
! ! |
4507 | 2557 |