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