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