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