author | Claus Gittinger <cg@exept.de> |
Tue, 03 Mar 2015 11:37:29 +0100 | |
changeset 5307 | 32c2e84b9c1d |
parent 5240 | 331c5840649e |
child 5484 | 73175b0903f9 |
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 |
||
182 |
examples |
|
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. |
333 | 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. |
262 |
field width:1.0. |
|
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. |
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. |
294 |
field width:1.0. |
|
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. |
312 |
field innerWidth:(field font widthOf:'00000000'). |
|
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. |
341 |
field width:1.0. |
|
342 |
field editValue:'hello'. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
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. |
|
369 |
field width:1.0. |
|
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 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
471 |
|
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] |
635 |
|top panel group field1 field2 field3 box |
|
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: |
681 |
update field2 wehenever field1 is changed. |
|
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 |
|
333 | 702 |
(top addInputFieldOn:value1 tabable:false) |
703 |
converter:(PrintConverter new initForNumberOrNil); |
|
704 |
immediateAccept:true. |
|
705 |
top addVerticalSpace. |
|
125 | 706 |
|
333 | 707 |
(top addTextLabel:'squared:') layout:#left. |
708 |
top addVerticalSpace. |
|
709 |
(top addInputFieldOn:value2 tabable:false) |
|
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 |
|
333 | 747 |
(top addInputFieldOn:value1 tabable:false) |
748 |
converter:(PrintConverter new initForNumberOrNil); |
|
749 |
immediateAccept:true. |
|
750 |
top addVerticalSpace. |
|
125 | 751 |
|
333 | 752 |
(top addTextLabel:'squared:') layout:#left. |
753 |
top addVerticalSpace. |
|
754 |
(top addInputFieldOn:value2 tabable:false) |
|
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 |
|
978 |
! |
|
979 |
||
192 | 980 |
crAction:aBlock |
981 |
"define an action to be evaluated when the return key is pressed." |
|
982 |
||
983 |
crAction := aBlock |
|
984 |
! |
|
125 | 985 |
|
3216 | 986 |
doubleClickAction:aBlock |
987 |
"define an action to be evaluated when being double clicked upon" |
|
988 |
||
989 |
doubleClickAction := aBlock |
|
990 |
! |
|
991 |
||
1034 | 992 |
enabled |
993 |
"return true, if the field is enabled (i.e. accepts keyboard input)" |
|
994 |
||
995 |
^ enabled ? true |
|
996 |
||
997 |
! |
|
998 |
||
1829 | 999 |
enabled:aBoolean |
1000 |
"enable/disable the field; show/hide the cursor and allow/disallow input" |
|
1001 |
||
1002 |
enabled ~~ aBoolean ifTrue:[ |
|
1003 |
enabled := aBoolean. |
|
1004 |
self updateBackground. |
|
1005 |
super cursorShown:aBoolean |
|
1006 |
] |
|
1007 |
||
1008 |
"Modified: / 3.8.1998 / 17:52:18 / cg" |
|
1009 |
"Created: / 30.3.1999 / 15:19:17 / stefan" |
|
1010 |
"Modified: / 30.3.1999 / 16:00:43 / stefan" |
|
1011 |
! |
|
1012 |
||
2993 | 1013 |
entryCompletionBlock |
1014 |
"the action to be evaluated when Tab (EntryCompletionCharacter) is pressed. |
|
1015 |
The block gets the current contents and the field itself as optional arguments |
|
1016 |
(i.e. it can be a 0, 1 or 2-arg block)." |
|
1017 |
||
1018 |
"/ read comment in entryCompletionBlockHolder: on why the following kludge is present |
|
1019 |
entryCompletionBlock isBlock ifTrue:[ |
|
1020 |
^ entryCompletionBlock |
|
1021 |
]. |
|
1022 |
^ entryCompletionBlock value |
|
1023 |
! |
|
1024 |
||
2995 | 1025 |
entryCompletionBlock:aZeroOneOrTwoArgBlock |
2993 | 1026 |
"define an action to be evaluated when Tab (EntryCompletionCharacter) is pressed. |
2628 | 1027 |
The block gets the current contents and the field itself as optional arguments |
1028 |
(i.e. it can be a 0, 1 or 2-arg block)." |
|
192 | 1029 |
|
2995 | 1030 |
entryCompletionBlock := aZeroOneOrTwoArgBlock |
125 | 1031 |
! |
1032 |
||
2995 | 1033 |
entryCompletionBlockHolder:aZeroOneOrTwoArgBlock |
2993 | 1034 |
"a holder for an action to be evaluated when Tab (EntryCompletionCharacter) is pressed. |
1035 |
The block gets the current contents and the field itself as optional arguments |
|
1036 |
(i.e. it can be a 0, 1 or 2-arg block)." |
|
1037 |
||
1038 |
"/ for now (to avoid incompatibilities), misuse the existing |
|
1039 |
"/ entryCompletionBlock and check if its a holder. |
|
1040 |
||
2995 | 1041 |
entryCompletionBlock := aZeroOneOrTwoArgBlock |
2993 | 1042 |
! |
1043 |
||
3990 | 1044 |
entryCompletionCharacter |
1045 |
"return the value of the instance variable 'entryCompletionCharacter' (automatically generated)" |
|
1046 |
||
1047 |
^ entryCompletionCharacter |
|
1048 |
! |
|
1049 |
||
192 | 1050 |
immediateAccept:aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1051 |
"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
|
1052 |
If true, every pressed key immediately accepts my |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1053 |
string into the valueHolder (if any)." |
155 | 1054 |
|
192 | 1055 |
immediateAccept := aBoolean |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1056 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1057 |
"Modified: 16.12.1995 / 16:25:57 / cg" |
192 | 1058 |
! |
155 | 1059 |
|
995 | 1060 |
isAcceptOnLeave |
1061 |
"return the acceptOnLeave flag. The default is false. |
|
1062 |
If true, leaving the box (via return, cursor etc.) accepts my |
|
1063 |
string into the valueHolder (if any). |
|
1064 |
(actually, the set of keys can be specified with #leaveKeys:)" |
|
1065 |
||
1066 |
^ acceptOnLeave |
|
1067 |
||
1068 |
"Modified: 11.12.1996 / 16:47:25 / cg" |
|
1069 |
! |
|
1070 |
||
1071 |
isAcceptOnLostFocus |
|
1072 |
"return the acceptOnLostFocus flag. The default is false. |
|
1073 |
If true, a lost focus (via mouse-pointer motion etc.) accepts my |
|
1074 |
string into the valueHolder (if any)." |
|
1075 |
||
1076 |
^ acceptOnLostFocus |
|
1077 |
||
1078 |
"Modified: 16.12.1995 / 16:26:45 / cg" |
|
1079 |
"Created: 11.12.1996 / 16:48:00 / cg" |
|
1080 |
! |
|
1081 |
||
1082 |
isAcceptOnReturn |
|
1083 |
"return the acceptOnReturn flag. The default is false. |
|
1084 |
If true, leaving the box via return accepts my |
|
1085 |
string into the valueHolder (if any)." |
|
1086 |
||
1087 |
^ acceptOnReturn |
|
1088 |
||
1089 |
"Modified: 16.12.1995 / 16:25:34 / cg" |
|
1090 |
! |
|
1091 |
||
1092 |
isAcceptOnTab |
|
1093 |
"return the acceptOnTab flag. The default is true. |
|
1094 |
If true, a pressed Tab key accepts and leaves the box. |
|
1095 |
If false, the Tab key is treated like any normal input character |
|
1096 |
(i.e. inserted into the contents)." |
|
1097 |
||
1098 |
^ acceptOnTab |
|
1099 |
! |
|
1100 |
||
994 | 1101 |
isImmediateAccept |
1102 |
"return the immediateAccept flag. The default is false. |
|
1103 |
If true, every pressed key immediately accepts my |
|
1104 |
string into the valueHolder (if any)." |
|
1105 |
||
1106 |
^ immediateAccept |
|
1107 |
||
1108 |
"Modified: 16.12.1995 / 16:25:57 / cg" |
|
1109 |
! |
|
1110 |
||
192 | 1111 |
leaveAction:aBlock |
4720 | 1112 |
"define an action to be evaluated when field is left by a leave-key |
1113 |
(by default: return or cursor keys. |
|
1114 |
Actually, the set of keys can be specified with #leaveKeys: |
|
1115 |
On leave, the precedence of actions is: |
|
1116 |
1) explicit leaveAction per key |
|
1117 |
2) this general leaveAction |
|
1118 |
3) tab or return action |
|
1119 |
" |
|
192 | 1120 |
|
1121 |
leaveAction := aBlock |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1122 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1123 |
"Modified: 16.12.1995 / 16:26:36 / cg" |
155 | 1124 |
! |
1125 |
||
3990 | 1126 |
leaveKey |
1127 |
"only valid after the editField has been left via a leaveCharacter. |
|
1128 |
Allows for users of the EditField to advance the selection |
|
1129 |
(especially: DataSets to select next/prev if editor is left via CrsrUp/Down)" |
|
1130 |
||
1131 |
^ leaveKey |
|
1132 |
! |
|
1133 |
||
1997 | 1134 |
leaveKeys |
1998 | 1135 |
"return (a copy of) the collection of keys which are interpreted as leaveKeys. |
1136 |
I.e. those that make the field inactive and pass the focus to the next field |
|
1137 |
(and accept, if acceptOnLeave is true)" |
|
1997 | 1138 |
|
1139 |
^ leaveKeys copy |
|
1140 |
! |
|
1141 |
||
192 | 1142 |
leaveKeys:aCollectionOfKeySymbols |
1143 |
"define the set of keys which are interpreted as leaveKeys. |
|
1144 |
I.e. those that make the field inactive and accept (if acceptOnLeave is true). |
|
1145 |
The default is a set of #CursorUp, #CursorDown, #Next, #Prior and #Return." |
|
155 | 1146 |
|
192 | 1147 |
leaveKeys := aCollectionOfKeySymbols |
1148 |
! |
|
155 | 1149 |
|
594 | 1150 |
makeTabable |
1151 |
"arrange for Tab to accept & leave the field |
|
1152 |
If the field is part of a group, the next field gets the |
|
1153 |
input focus" |
|
1154 |
||
1155 |
leaveKeys isNil ifTrue:[ |
|
1156 |
leaveKeys := self class defaultLeaveKeys |
|
1157 |
]. |
|
1158 |
leaveKeys := leaveKeys copyWith:#Tab |
|
1159 |
||
1160 |
"Created: 27.4.1996 / 17:09:48 / cg" |
|
1161 |
! |
|
1162 |
||
4720 | 1163 |
onKey:aKey leaveWith:aBlock |
1164 |
"arrange for aKey to leave the field and evalaute aBlock. |
|
1165 |
On leave, the precedence of actions is: |
|
1166 |
1) explicit leaveAction per key |
|
1167 |
2) general leaveAction |
|
1168 |
3) tab or return action |
|
1169 |
Can be used to arrange for cursorDown to pass focus to another widget." |
|
1170 |
||
4724 | 1171 |
leaveKeys := leaveKeys asOrderedCollection. |
4720 | 1172 |
leaveKeys add:aKey. |
1173 |
leaveKeyActions isNil ifTrue:[ |
|
1174 |
leaveKeyActions := Dictionary new. |
|
1175 |
]. |
|
1176 |
leaveKeyActions at:aKey put:aBlock. |
|
1177 |
! |
|
1178 |
||
1609
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1179 |
readOnly:aBoolean |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1180 |
"make the text readonly or writable" |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1181 |
|
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1182 |
super readOnly:aBoolean. |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
1183 |
self updateBackground. |
1609
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1184 |
|
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1185 |
"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
|
1186 |
"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
|
1187 |
! |
8a0c1ee30a0a
readOnly fields change the backgroundColor to grey.
Claus Gittinger <cg@exept.de>
parents:
1547
diff
changeset
|
1188 |
|
1842 | 1189 |
returnKeyIsFocusNext |
1190 |
"arrange for the return key to act as a focus-next key" |
|
1191 |
||
3975
73674d16fc63
copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
1192 |
leaveKeys := leaveKeys copyAsOrderedCollection. |
1842 | 1193 |
leaveKeys remove:#Return ifAbsent:nil |
1194 |
! |
|
1195 |
||
192 | 1196 |
tabAction:aBlock |
1197 |
"define an action to be evaluated when the tabulator key is pressed." |
|
155 | 1198 |
|
192 | 1199 |
tabAction := aBlock |
594 | 1200 |
! |
1201 |
||
1202 |
tabKey:aKeySymbol |
|
1203 |
"arrange for aKeySymbol to accept & leave the field |
|
1204 |
If the field is part of a group, the next field gets the |
|
1205 |
input focus" |
|
1206 |
||
1207 |
leaveKeys isNil ifTrue:[ |
|
1208 |
leaveKeys := self class defaultLeaveKeys |
|
1209 |
]. |
|
1210 |
leaveKeys := leaveKeys copyWith:#Tab |
|
1211 |
||
1212 |
"Created: 27.4.1996 / 17:08:54 / cg" |
|
187 | 1213 |
! ! |
125 | 1214 |
|
187 | 1215 |
!EditField methodsFor:'accessing-contents'! |
125 | 1216 |
|
187 | 1217 |
contents |
1218 |
"return contents as a string |
|
1219 |
- redefined since EditFields hold only one line of text. |
|
1220 |
In your application, please use #editValue; |
|
1221 |
it uses a converter (if any) and is compatible to ST-80." |
|
1222 |
||
3706
d25f10e7b49b
#accept only, if the text field has been modified (DrawAdaptor compatibility)
Stefan Vogel <sv@exept.de>
parents:
3704
diff
changeset
|
1223 |
(list isEmptyOrNil) ifTrue:[^ '']. |
187 | 1224 |
^ list at:1 |
1225 |
! |
|
1226 |
||
125 | 1227 |
contents:someText |
1228 |
"set the contents from a string |
|
1229 |
- 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
|
1230 |
In your application, please use #editValue: - |
125 | 1231 |
it uses a converter (if any) and is compatible to ST-80." |
1232 |
||
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1233 |
|newCol txt| |
187 | 1234 |
|
1235 |
newCol := cursorCol. |
|
1236 |
||
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1237 |
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
|
1238 |
txt := ''. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1239 |
] ifFalse:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1240 |
txt := someText asString. |
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1241 |
]. |
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1242 |
super contents:txt. |
125 | 1243 |
|
2130
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1244 |
(cursorMovementWhenUpdating == #endOfLine |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1245 |
or:[cursorMovementWhenUpdating == #endOfText |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1246 |
or:[cursorMovementWhenUpdating == #end]]) ifTrue:[ |
1180
abe00ac05e27
oops - care for nil contents
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1247 |
newCol := (txt size + 1). |
187 | 1248 |
] ifFalse:[ |
2130
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1249 |
(cursorMovementWhenUpdating == #beginOfLine |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1250 |
or:[cursorMovementWhenUpdating == #beginOfText |
40515380f762
moved control over how-to-move-the-cursor when updating text
Claus Gittinger <cg@exept.de>
parents:
2105
diff
changeset
|
1251 |
or:[cursorMovementWhenUpdating == #begin]]) ifTrue:[ |
1179 | 1252 |
newCol := 1 |
1253 |
] ifFalse:[ |
|
1254 |
"/ default: stay where it was |
|
1255 |
] |
|
187 | 1256 |
]. |
125 | 1257 |
|
187 | 1258 |
self cursorCol:newCol. |
1179 | 1259 |
|
2042 | 1260 |
"Modified: / 13.11.1999 / 13:50:30 / cg" |
125 | 1261 |
! |
1262 |
||
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1263 |
convertEditValueToString:aStringOrObject |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1264 |
"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
|
1265 |
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
|
1266 |
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
|
1267 |
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
|
1268 |
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
|
1269 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1270 |
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
|
1271 |
^ 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
|
1272 |
]. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1273 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1274 |
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
|
1275 |
^ ''. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1276 |
]. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1277 |
^ aStringOrObject asString. |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1278 |
! |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1279 |
|
125 | 1280 |
editValue |
1281 |
"if the field edits a string, this is a name alias for #contents. |
|
1282 |
Otherwise, if there is a converter, return the edited string |
|
1283 |
converted to an appropriate object." |
|
1284 |
||
1285 |
|string| |
|
1286 |
||
1287 |
string := self contents. |
|
279 | 1288 |
string isNil ifTrue:[string := '']. |
125 | 1289 |
converter isNil ifTrue:[^ string]. |
1290 |
^ converter readValueFrom:string |
|
1291 |
! |
|
0 | 1292 |
|
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1293 |
editValue:anObject |
125 | 1294 |
"set the contents. If there is a converter, use it to convert |
1295 |
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
|
1296 |
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
|
1297 |
(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
|
1298 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1299 |
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
|
1300 |
! |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1301 |
|
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1302 |
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
|
1303 |
"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
|
1304 |
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
|
1305 |
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
|
1306 |
(i.e. this is equivalent to sending #initialText:selected:)." |
125 | 1307 |
|
1308 |
|string| |
|
1309 |
||
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1310 |
string := self convertEditValueToString:anObject. |
125 | 1311 |
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
|
1312 |
isSelected ifTrue:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1313 |
self selectFromLine:1 col:1 toLine:1 col:string size. |
125 | 1314 |
] |
1315 |
! |
|
1316 |
||
192 | 1317 |
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
|
1318 |
"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
|
1319 |
Better use #editValue: - it uses the type converter." |
192 | 1320 |
|
1321 |
self initialText:aString selected:true |
|
1322 |
! |
|
1323 |
||
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1324 |
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
|
1325 |
"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
|
1326 |
Better use #editValue:selected: - it uses the type converter." |
187 | 1327 |
|
1328 |
|len s| |
|
125 | 1329 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1330 |
viewOrigin := 0 @ viewOrigin y. |
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1331 |
|
3709
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1332 |
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
|
1333 |
isSelected ifTrue:[ |
a17acdae3e35
Modify previous change: only change the model, if the EditField's text
Stefan Vogel <sv@exept.de>
parents:
3706
diff
changeset
|
1334 |
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
|
1335 |
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
|
1336 |
len ~~ 0 ifTrue:[ |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1337 |
self selectFromLine:1 col:1 toLine:1 col:len |
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
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 |
]. |
187 | 1340 |
! |
1341 |
||
192 | 1342 |
list:someText |
1343 |
"low level access to the underlying contents' list. |
|
1344 |
Redefined to force text to 1 line, and notify dependents |
|
1345 |
of any changed extent-wishes (for automatic box resizing)." |
|
1346 |
||
1347 |
|l oldWidth| |
|
187 | 1348 |
|
192 | 1349 |
l := someText. |
4992 | 1350 |
l notEmptyOrNil ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1351 |
l := OrderedCollection with:(l at:1) |
192 | 1352 |
]. |
1353 |
oldWidth := self widthOfContents. |
|
1354 |
super list:l. |
|
1355 |
self widthOfContents ~~ oldWidth ifTrue:[ |
|
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1356 |
self changedPreferredBounds:nil |
192 | 1357 |
] |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1358 |
|
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1359 |
"Modified: 6.3.1997 / 16:13:36 / cg" |
187 | 1360 |
! |
1361 |
||
1362 |
stringValue |
|
1363 |
"alias for #contents - for compatibility with ST-80's InputField" |
|
1364 |
||
1365 |
^ self contents |
|
1366 |
! ! |
|
1367 |
||
1368 |
!EditField methodsFor:'accessing-look'! |
|
125 | 1369 |
|
3585 | 1370 |
bePassword |
1371 |
"make me a password entry field (i.e. show *'s for typed characters" |
|
1372 |
||
1373 |
self passwordCharacter:$* |
|
1374 |
! |
|
1375 |
||
3990 | 1376 |
emptyFieldReplacementText |
3991 | 1377 |
"the string to show in grey if nothing has been entered (and the field is passive)" |
3990 | 1378 |
|
1379 |
^ emptyFieldReplacementText |
|
1380 |
! |
|
1381 |
||
1382 |
emptyFieldReplacementText:something |
|
3991 | 1383 |
"the string to show in grey if nothing has been entered (and the field is passive)" |
3990 | 1384 |
|
1385 |
emptyFieldReplacementText := something. |
|
1386 |
! |
|
1387 |
||
4989 | 1388 |
font:aFont |
1389 |
super font:aFont. |
|
5044 | 1390 |
realized ifTrue:[ self computeTopMargin ]. |
4989 | 1391 |
! |
1392 |
||
155 | 1393 |
maxChars |
1394 |
"return the maximum number of characters that are allowed in |
|
1395 |
the field. |
|
1396 |
A limit of nil means: unlimited. This is the default." |
|
1397 |
||
1398 |
^ lengthLimit |
|
1399 |
||
1400 |
"Modified: 6.9.1995 / 13:43:33 / claus" |
|
1401 |
! |
|
1402 |
||
125 | 1403 |
maxChars:aNumberOrNil |
1404 |
"set the maximum number of characters that are allowed in |
|
1405 |
the field. Additional input will be ignored by the field. |
|
1034 | 1406 |
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
|
1407 |
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
|
1408 |
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
|
1409 |
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
|
1410 |
|
125 | 1411 |
This method has been renamed from #lengthLimit: for ST-80 |
1412 |
compatibility." |
|
1413 |
||
1034 | 1414 |
aNumberOrNil == 0 ifTrue:[ |
1415 |
lengthLimit := nil |
|
1416 |
] ifFalse:[ |
|
1417 |
lengthLimit := aNumberOrNil. |
|
1418 |
] |
|
187 | 1419 |
! |
1420 |
||
192 | 1421 |
passwordCharacter |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1422 |
"return the passwordCharacter; |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1423 |
If nonNil, that one is replacing typed input |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1424 |
(for secret input)" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1425 |
|
192 | 1426 |
^ passwordCharacter |
0 | 1427 |
|
192 | 1428 |
"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
|
1429 |
"Modified: 16.12.1995 / 16:24:25 / cg" |
125 | 1430 |
! |
1431 |
||
192 | 1432 |
passwordCharacter:aCharacter |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1433 |
"set the passwordCharacter; |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1434 |
If nonNil, that one is replacing typed input |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1435 |
(for secret input)" |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
1436 |
|
192 | 1437 |
passwordCharacter := aCharacter |
97 | 1438 |
|
192 | 1439 |
"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
|
1440 |
"Modified: 16.12.1995 / 16:24:33 / cg" |
38 | 1441 |
! ! |
1442 |
||
1829 | 1443 |
!EditField methodsFor:'cursor drawing'! |
1444 |
||
1445 |
cursorShown:aBoolean |
|
1446 |
"make cursor visible if currently invisible - but only if this |
|
1880 | 1447 |
EditField is enabled. |
1448 |
Return the previous cursor-shown-state" |
|
1399 | 1449 |
|
1836 | 1450 |
^ super cursorShown:(aBoolean and:[enabled and:[self isReadOnly not]]) |
1399 | 1451 |
|
1829 | 1452 |
"Created: / 30.3.1999 / 16:00:25 / stefan" |
1880 | 1453 |
"Modified: / 1.4.1999 / 11:18:38 / cg" |
1829 | 1454 |
! |
0 | 1455 |
|
155 | 1456 |
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg |
1457 |
startVisLineNr to:endVisLineNr do:[:visLine | |
|
1458 |
self drawVisibleLine:visLine with:fg and:bg |
|
1459 |
] |
|
1460 |
||
1461 |
"Modified: 6.9.1995 / 12:24:29 / claus" |
|
0 | 1462 |
! ! |
1463 |
||
1464 |
!EditField methodsFor:'cursor movement'! |
|
1465 |
||
1466 |
cursorDown |
|
1467 |
"catch cursor movement" |
|
1468 |
||
1469 |
(cursorVisibleLine == nLinesShown) ifFalse:[ |
|
59 | 1470 |
super cursorDown |
0 | 1471 |
] |
192 | 1472 |
! |
1473 |
||
1474 |
cursorLine:line col:col |
|
1475 |
"catch cursor movement" |
|
1476 |
||
1477 |
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
|
1478 |
! |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1479 |
|
5055 | 1480 |
cursorLine:line col:col makeVisible:aBoolean |
1481 |
"catch cursor movement" |
|
1482 |
||
1483 |
super cursorLine:1 col:col makeVisible:aBoolean |
|
1484 |
! |
|
1485 |
||
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1486 |
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
|
1487 |
"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
|
1488 |
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
|
1489 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1490 |
|sz| |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1491 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1492 |
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
|
1493 |
lengthLimit notNil ifTrue:[ |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1494 |
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
|
1495 |
]. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1496 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1497 |
col <= sz ifTrue:[ |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1498 |
^ col |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1499 |
]. |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1500 |
^ 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
|
1501 |
|
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1502 |
"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
|
1503 |
"Modified: 22.5.1996 / 18:19:04 / cg" |
192 | 1504 |
! ! |
1505 |
||
3413 | 1506 |
!EditField methodsFor:'drag & drop'! |
1507 |
||
1508 |
dropFileObject:aDropObject |
|
1509 |
"drop objects |
|
1510 |
Redefined to always drop the name only" |
|
1511 |
||
3797 | 1512 |
self |
4115 | 1513 |
undoablePasteReplacingAll:(aDropObject asFilename pathName) |
3797 | 1514 |
info:'Drop Filename'. |
3413 | 1515 |
|
1516 |
"Created: / 13-10-2006 / 17:42:22 / cg" |
|
3494 | 1517 |
"Modified: / 28-07-2007 / 13:27:32 / cg" |
3413 | 1518 |
! ! |
1519 |
||
192 | 1520 |
!EditField methodsFor:'editing'! |
1521 |
||
1522 |
paste:someText |
|
1523 |
"redefined to force text to 1 line" |
|
1524 |
||
1525 |
super paste:someText. |
|
1526 |
list size > 1 ifTrue:[ |
|
1527 |
self deleteFromLine:2 toLine:(list size) |
|
1528 |
] |
|
0 | 1529 |
! ! |
1530 |
||
70 | 1531 |
!EditField methodsFor:'event handling'! |
19 | 1532 |
|
192 | 1533 |
buttonPress:button x:x y:y |
1534 |
"enable myself on mouse click" |
|
1535 |
||
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1536 |
|prevFocus| |
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1537 |
|
3703
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1538 |
enabled ifTrue:[ |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1539 |
prevFocus := hasKeyboardFocus. |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1540 |
clickAction notNil ifTrue:[ |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1541 |
clickAction value:self |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1542 |
]. |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1543 |
hasKeyboardFocus ~~ prevFocus ifTrue:[ |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1544 |
^ self |
5463ea3878b0
you can copy from the menu even if disabled.
Claus Gittinger <cg@exept.de>
parents:
3702
diff
changeset
|
1545 |
]. |
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1546 |
]. |
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1547 |
super buttonPress:button x:x y:y |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1548 |
|
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1549 |
"/ enabled ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1550 |
"/ enabled := true. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1551 |
"/ super buttonPress:button x:x y:y. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1552 |
"/ enableAction notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1553 |
"/ enableAction value |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1554 |
"/ ] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1555 |
"/ ] ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1556 |
"/ super buttonPress:button x:x y:y |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1557 |
"/ ] |
333 | 1558 |
|
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1559 |
"Modified: 22.5.1996 / 15:02:45 / cg" |
192 | 1560 |
! |
1561 |
||
1562 |
canHandle:aKey |
|
1563 |
"return true, if the receiver would like to handle aKey |
|
1564 |
(usually from another view, when the receiver is part of |
|
1565 |
a more complex dialog box). |
|
1566 |
We do return true here, since the editfield will handle |
|
1567 |
all keys. |
|
1568 |
OBSOLETE: dont use this anymore - its a leftover for the tableWidget" |
|
1569 |
||
1570 |
^ true |
|
1571 |
! |
|
1572 |
||
3216 | 1573 |
doubleClickX:x y:y |
1574 |
doubleClickAction notNil ifTrue: [ |
|
1575 |
doubleClickAction value. |
|
1576 |
]. |
|
1577 |
||
1578 |
super doubleClickX:x y:y |
|
1579 |
! |
|
1580 |
||
4608 | 1581 |
handleCompletionService |
1582 |
"none here" |
|
1583 |
||
1584 |
^ self |
|
1585 |
! |
|
1586 |
||
3460 | 1587 |
handleFocusKey:key |
3535 | 1588 |
"handle a focus key, to assign the focus to another field in my group" |
1589 |
||
3460 | 1590 |
<resource: #keyboard (#Tab #Return #CursorDown #CursorUp)> |
1591 |
||
1592 |
windowGroup isNil ifTrue:[^ self ]. |
|
1593 |
||
1594 |
(key == #Tab) ifTrue:[ |
|
1595 |
(self tabRequiresControl not |
|
1596 |
or:[ self sensor ctrlDown ]) ifTrue:[ |
|
1597 |
self sensor shiftDown ifTrue:[ |
|
1598 |
windowGroup focusPrevious |
|
1599 |
] ifFalse:[ |
|
1600 |
windowGroup focusNext |
|
1601 |
]. |
|
1602 |
]. |
|
1603 |
^ self |
|
1604 |
]. |
|
1605 |
||
1606 |
(key == #Return) ifTrue:[ |
|
1607 |
windowGroup focusNext. |
|
1608 |
^ self |
|
1609 |
]. |
|
1610 |
||
1611 |
key == #CursorDown ifTrue:[ |
|
1612 |
windowGroup focusNext. |
|
1613 |
^ self. |
|
1614 |
]. |
|
1615 |
key == #CursorUp ifTrue:[ |
|
1616 |
windowGroup focusPrevious. |
|
1617 |
^ self. |
|
1618 |
]. |
|
1619 |
||
1620 |
"Created: / 06-03-2007 / 20:14:04 / cg" |
|
1621 |
! |
|
1622 |
||
125 | 1623 |
keyPress:key x:x y:y |
1624 |
"if keyHandler is defined, pass input; otherwise check for leave |
|
1625 |
keys" |
|
1626 |
||
490 | 1627 |
<resource: #keyboard (#Tab #Return #Find #FindNext #FindPrev |
922 | 1628 |
#DeleteLine #GotoLine #EndOfLine #EndOfText |
1629 |
#CursorDown #CursorUp)> |
|
132 | 1630 |
|
4992 | 1631 |
|leave oldContents newContents doAccept keyAction numArgs| |
125 | 1632 |
|
1633 |
enabled ifFalse:[ |
|
325 | 1634 |
^ self |
125 | 1635 |
]. |
1636 |
||
1637 |
(key == #DeleteLine) ifTrue:[ |
|
325 | 1638 |
Smalltalk at:#CopyBuffer put:(self contents). |
3797 | 1639 |
self contents:''. |
1640 |
^ self |
|
125 | 1641 |
]. |
19 | 1642 |
|
3460 | 1643 |
(key == entryCompletionCharacter and:[self entryCompletionBlock notNil]) ifTrue:[ |
979 | 1644 |
oldContents := self contents. |
1645 |
oldContents isNil ifTrue:[ |
|
1646 |
oldContents := '' |
|
1647 |
] ifFalse:[ |
|
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1648 |
oldContents := oldContents asString |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1649 |
]. |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1650 |
|
2993 | 1651 |
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
|
1652 |
|
979 | 1653 |
newContents := self contents. |
1654 |
newContents isNil ifTrue:[ |
|
1655 |
newContents := '' |
|
1656 |
] ifFalse:[ |
|
1657 |
newContents := newContents asString |
|
1658 |
]. |
|
1659 |
newContents ~= oldContents ifTrue:[ |
|
1660 |
self textChanged |
|
1661 |
]. |
|
1662 |
^ self |
|
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1663 |
]. |
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1664 |
|
125 | 1665 |
(key == #Tab) ifTrue:[ |
3460 | 1666 |
doAccept := acceptOnTab. |
1667 |
keyAction := tabAction. |
|
1668 |
]. |
|
1669 |
(key == #Return) ifTrue:[ |
|
1670 |
doAccept := acceptOnReturn. |
|
1671 |
keyAction := crAction. |
|
1672 |
]. |
|
1673 |
||
1674 |
leave := leaveKeys includes:key. |
|
1675 |
leave ifTrue:[ |
|
1676 |
leaveKey := key. |
|
1677 |
doAccept := doAccept ? acceptOnLeave. |
|
4720 | 1678 |
|
1679 |
"/ on leave, the precedence of actions is: |
|
1680 |
"/ 1) explicit leaveAction per key |
|
1681 |
"/ 2) general leaveAction |
|
1682 |
"/ 3) tab or return action |
|
1683 |
leaveKeyActions notNil ifTrue:[ |
|
4979 | 1684 |
keyAction := leaveKeyActions at:key ifAbsent:[keyAction]. |
4720 | 1685 |
]. |
3460 | 1686 |
keyAction := keyAction ? leaveAction. |
1687 |
]. |
|
1688 |
||
1689 |
doAccept == true ifTrue:[ |
|
1690 |
self accept. |
|
1691 |
]. |
|
1692 |
||
1693 |
keyAction notNil ifTrue:[ |
|
3462
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1694 |
numArgs := keyAction numArgs. |
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1695 |
|
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1696 |
numArgs == 2 ifTrue:[ |
3460 | 1697 |
^ 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
|
1698 |
]. |
3462
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1699 |
numArgs == 0 ifTrue:[ |
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1700 |
^ keyAction value |
447eb65a523f
check for numArgs == 0 before evaluating the keyAction
boris
parents:
3461
diff
changeset
|
1701 |
]. |
3460 | 1702 |
^ keyAction value:key |
125 | 1703 |
]. |
480 | 1704 |
|
125 | 1705 |
leave ifTrue:[ |
611
87637cf3931b
Handle keypress:key x:nil y:nil correctly (means recursion).
Stefan Vogel <sv@exept.de>
parents:
601
diff
changeset
|
1706 |
(x notNil and:[x >= 0]) ifTrue:[ |
325 | 1707 |
" |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1708 |
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
|
1709 |
let superview know about the key that caused us to leave (maybe RETURN, DOWN, UP etc.... |
325 | 1710 |
" |
1711 |
(superView notNil and:[superView canHandle:key from:self]) ifTrue:[ |
|
1712 |
superView keyPress:key x:x y:y. |
|
1713 |
]. |
|
1714 |
]. |
|
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1715 |
|
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1716 |
"/ 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
|
1717 |
"/ 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
|
1718 |
key == #CursorDown ifTrue:[ |
3460 | 1719 |
self handleFocusKey:key. |
2708
dfdf8977e9ba
care for nil windogroup (editor in dataSet)
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
1720 |
^ self. |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1721 |
]. |
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1722 |
key == #CursorUp ifTrue:[ |
3460 | 1723 |
self handleFocusKey:key. |
2708
dfdf8977e9ba
care for nil windogroup (editor in dataSet)
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
1724 |
^ self. |
737
911a168ef967
handle leave from EditField without a group as a focus-stepping
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
1725 |
]. |
325 | 1726 |
^ self |
19 | 1727 |
]. |
121 | 1728 |
|
125 | 1729 |
" |
1730 |
ignore some keys (if not a leaveKey) ... |
|
1731 |
" |
|
1732 |
(key == #Find) ifTrue:[^self]. |
|
1733 |
(key == #FindNext) ifTrue:[^self]. |
|
1734 |
(key == #FindPrev) ifTrue:[^self]. |
|
1735 |
(key == #GotoLine) ifTrue:[^self]. |
|
1736 |
" |
|
1737 |
a normal key - let superclass's method insert it |
|
1738 |
" |
|
1739 |
super keyPress:key x:x y:y. |
|
1740 |
||
1741 |
" |
|
1742 |
for end-of-text, also move to end-of-line |
|
1743 |
" |
|
1744 |
key == #EndOfText ifTrue:[ |
|
325 | 1745 |
super keyPress:#EndOfLine x:x y:y. |
125 | 1746 |
]. |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1747 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1748 |
self resizeOrScroll. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1749 |
|
3460 | 1750 |
"Modified: / 02-05-1996 / 17:24:16 / stefan" |
4212 | 1751 |
"Modified: / 17-01-2011 / 11:26:08 / cg" |
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1752 |
! |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1753 |
|
1936 | 1754 |
pointerLeave:state |
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
1755 |
(acceptOnPointerLeave and:[enabled and:[self modified]]) ifTrue:[ |
1936 | 1756 |
self accept |
1757 |
]. |
|
1758 |
super pointerLeave:state |
|
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
1759 |
|
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
1760 |
"Modified: / 28.6.1999 / 18:08:29 / cg" |
1936 | 1761 |
! |
1762 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1763 |
resizeOrScroll |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1764 |
"helper for keyPress. |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1765 |
Extracted for easier subclass redefinition." |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1766 |
|
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1767 |
|xCol newOffset newWidth| |
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1768 |
|
125 | 1769 |
newWidth := self widthOfContents. |
1770 |
||
1771 |
" |
|
1772 |
should (& can) we resize ? |
|
1773 |
" |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1774 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - viewOrigin x. |
125 | 1775 |
(xCol > (width * (5/6))) ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1776 |
self changedPreferredBounds:nil |
125 | 1777 |
] ifFalse:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1778 |
newWidth < (width * (1/6)) ifTrue:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1779 |
self changedPreferredBounds:nil |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1780 |
] |
125 | 1781 |
]. |
1782 |
||
290
f539121393b1
innerWidth:/innerHeight support; much more docu in editField
Claus Gittinger <cg@exept.de>
parents:
279
diff
changeset
|
1783 |
autoScrollHorizontally ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1784 |
" |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1785 |
did someone react (i.e. has my extent changed) ? |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1786 |
(if not, we scroll horizontally) |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1787 |
" |
2016
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1788 |
lengthLimit notNil ifTrue:[ |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1789 |
(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
|
1790 |
ifTrue:[ |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1791 |
^ self |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1792 |
]. |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1793 |
]. |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
1794 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1795 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - viewOrigin x. |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1796 |
(xCol > (width * (5/6))) ifTrue:[ |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1797 |
newOffset := viewOrigin x + (width // 2). |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1798 |
] ifFalse:[ |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1799 |
(xCol < (width * (1/6))) ifTrue:[ |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1800 |
newOffset := 0 max: viewOrigin x - (width // 2). |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1801 |
] ifFalse:[ |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1802 |
newOffset := viewOrigin x |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1803 |
] |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1804 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1805 |
newOffset ~~ viewOrigin x ifTrue:[ |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1806 |
self scrollHorizontalTo:newOffset. |
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1807 |
] |
125 | 1808 |
]. |
1103
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1809 |
|
0efbd1ac68f4
use new #changedPreferredBounds
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1810 |
"Modified: 6.3.1997 / 16:13:59 / cg" |
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1811 |
! |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
1812 |
|
784
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1813 |
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
|
1814 |
"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
|
1815 |
|
1282 | 1816 |
|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
|
1817 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
1818 |
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
|
1819 |
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
|
1820 |
(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
|
1821 |
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
|
1822 |
]. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1823 |
]. |
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1824 |
self makeCursorVisible. |
4989 | 1825 |
super sizeChanged:how. |
1826 |
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
|
1827 |
|
4161490a4b6d
scroll to origin, if size changes and all text fits into the view.
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1828 |
"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
|
1829 |
! |
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1830 |
|
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1831 |
tripleClickX:x y:y |
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1832 |
"triple-click - select all" |
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1833 |
|
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1834 |
self selectAll |
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1835 |
|
f3349579b8d3
Added EditField>>#tripleClickX:y:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4979
diff
changeset
|
1836 |
"Created: / 09-04-2014 / 19:04:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
192 | 1837 |
! ! |
1838 |
||
1806 | 1839 |
!EditField methodsFor:'focus handling'! |
1840 |
||
1841 |
hasKeyboardFocus:aBoolean |
|
1842 |
"the view got/lost the keyboard focus" |
|
1843 |
||
4930 | 1844 |
|hadKeyboardFocus| |
1845 |
||
1846 |
hadKeyboardFocus := hasKeyboardFocus. |
|
1847 |
super hasKeyboardFocus:aBoolean. |
|
1848 |
||
1849 |
(acceptOnLostFocus and:[enabled and:[aBoolean not and:[hadKeyboardFocus]]]) ifTrue:[ |
|
1850 |
model notNil ifTrue:[ |
|
1851 |
model value = self argForChangeMessage ifTrue:[ |
|
1852 |
^ self |
|
1853 |
] |
|
1806 | 1854 |
]. |
4930 | 1855 |
self accept. |
1806 | 1856 |
]. |
1857 |
||
1858 |
"Created: / 11.12.1996 / 16:57:50 / cg" |
|
1859 |
"Modified: / 6.12.1997 / 14:07:12 / cg" |
|
1860 |
! |
|
1861 |
||
1862 |
showFocus:explicit |
|
1863 |
"the view got the keyboard focus |
|
1864 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
1865 |
- change any display attributes as req'd." |
|
1866 |
||
1867 |
"/ giving me the focus is like clicking on me |
|
1868 |
"/ (tell my enterFieldGroup ...) |
|
1869 |
||
1870 |
||
1871 |
(enabled or:[explicit]) ifTrue:[ |
|
5240 | 1872 |
super showFocus:explicit. |
1806 | 1873 |
clickAction notNil ifTrue:[clickAction value:self]. |
3461 | 1874 |
"/ mhmh - should we ALWAYS do this ? |
5240 | 1875 |
true "explicit" ifTrue:[ self makeCursorVisible ]. |
1806 | 1876 |
] |
1877 |
||
3461 | 1878 |
"Modified: / 06-03-2007 / 21:11:17 / cg" |
1806 | 1879 |
! |
1880 |
||
1881 |
showNoFocus:explicit |
|
1882 |
"the view lost the keyboard focus |
|
1883 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
1884 |
- change any display attributes as req'd." |
|
1885 |
||
1886 |
self hideCursor. |
|
1887 |
super showNoFocus:explicit |
|
1888 |
||
1889 |
"Modified: / 17.9.1998 / 15:10:04 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1890 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1891 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1892 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1893 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1894 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1912
diff
changeset
|
1895 |
|
4992 | 1896 |
^ UserPreferences current focusFollowsMouse ~~ false |
1897 |
and:[(styleSheet at:#'editField.requestFocusOnPointerEnter' default:true) |
|
1898 |
and:[self enabled |
|
1899 |
and:[self isReadOnly not]]] |
|
1806 | 1900 |
! ! |
1901 |
||
2750 | 1902 |
!EditField methodsFor:'initialization & release'! |
192 | 1903 |
|
4989 | 1904 |
computeTopMargin |
5043 | 1905 |
|innerHeight rest font fontHeight fontDescent| |
4989 | 1906 |
|
1907 |
innerHeight := self innerHeight. |
|
5044 | 1908 |
innerHeight <= 0 ifTrue:[ textStartTop := 0. ^ self ]. |
1909 |
||
5043 | 1910 |
font := gc font. |
1911 |
fontHeight := font height. |
|
1912 |
fontDescent := font descent. |
|
1913 |
rest := innerHeight - (fontHeight + (fontDescent // 2)). |
|
4989 | 1914 |
rest > 1 ifTrue:[ |
1915 |
textStartTop := (rest // 2) + margin + topMargin |
|
5043 | 1916 |
] ifFalse:[ |
1917 |
"/ care if font is too high for my height: |
|
1918 |
"/ shift baseline towards the top, so that the same is cut off at both ends. |
|
1919 |
"/ (the heuristic fontDescent//3) gives a few pixels more at the top) |
|
5044 | 1920 |
textStartTop := 1 "(fontDescent//3)" - ((font ascent + fontDescent - innerHeight) // 2). |
1921 |
]. |
|
4989 | 1922 |
! |
1923 |
||
192 | 1924 |
initStyle |
967 | 1925 |
"setup viewStyle specifics" |
1926 |
||
3265 | 1927 |
<resource: #style (#'editField.cursorType' |
1928 |
#'editField.cursorForegroundColor' |
|
4013 | 1929 |
#'editField.cursorBackgroundColor' |
3265 | 1930 |
)> |
1931 |
||
192 | 1932 |
super initStyle. |
1933 |
||
4989 | 1934 |
self computeTopMargin. |
1935 |
||
192 | 1936 |
DefaultBackgroundColor notNil ifTrue:[ |
4896 | 1937 |
bgColor := DefaultBackgroundColor onDevice:self graphicsDevice. |
1482 | 1938 |
"/ bgColor ditherForm notNil ifTrue:[ |
4896 | 1939 |
"/ bgColor := (bgColor copy) exactOrNearestOn:self graphicsDevice |
1482 | 1940 |
"/ ]. |
967 | 1941 |
self viewBackground:bgColor. |
192 | 1942 |
]. |
1943 |
fgColor := DefaultForegroundColor. |
|
1944 |
selectionFgColor := DefaultSelectionForegroundColor. |
|
1945 |
selectionBgColor := DefaultSelectionBackgroundColor. |
|
967 | 1946 |
|
1544
bb7e168dd651
dont hide editFields non-focus cursor (for now - focusDetection must be fixed)
Claus Gittinger <cg@exept.de>
parents:
1542
diff
changeset
|
1947 |
"/ enable this, when the focus detection works correctly (in dialogs) |
1848 | 1948 |
cursorTypeNoFocus := #none. |
1949 |
||
1950 |
cursorType := styleSheet at:#'editField.cursorType' default:cursorType. |
|
1951 |
||
1952 |
cursorFgColor := styleSheet at:#'editField.cursorForegroundColor' default:cursorFgColor. |
|
1953 |
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
|
1954 |
|
4013 | 1955 |
DefaultLevel notNil ifTrue:[ |
1956 |
self level:DefaultLevel. |
|
1957 |
]. |
|
1958 |
DefaultBorderWidth notNil ifTrue:[ |
|
1959 |
self borderWidth:DefaultBorderWidth. |
|
1960 |
DefaultBorderColor notNil ifTrue:[ |
|
1961 |
self borderColor:DefaultBorderColor. |
|
1962 |
]. |
|
1963 |
]. |
|
1964 |
||
4320 | 1965 |
"Modified: / 21-05-1998 / 15:38:14 / cg" |
1966 |
"Modified (comment): / 05-10-2011 / 15:51:15 / az" |
|
192 | 1967 |
! |
0 | 1968 |
|
192 | 1969 |
initialize |
1970 |
super initialize. |
|
4888 | 1971 |
self initialHeight:(gc font height + gc 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
|
1972 |
|
192 | 1973 |
nFullLinesShown := 1. |
1974 |
nLinesShown := 1. |
|
1225
6220d3bd3033
initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
1975 |
trimBlankLines := immediateAccept := acceptOnLostFocus := false. |
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
1976 |
acceptOnPointerLeave := false. |
1225
6220d3bd3033
initialize acceptOnLostFocus
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
1977 |
enabled := fixedSize := autoScrollHorizontally := true. |
298
932fa5ca44f8
added more control over tab-key behavior (acceptOnTab:); added more examples & docu
ah
parents:
290
diff
changeset
|
1978 |
acceptOnLeave := acceptOnReturn := acceptOnTab := true. |
192 | 1979 |
cursorShown := true. |
978
6e678fdc6e5b
allow non-Tab as entryCompleter; care for immediateAccept after completion
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1980 |
entryCompletionCharacter := #Tab. |
2105 | 1981 |
acceptIfUnchanged := false. |
673
e5a4bcfc960e
use new cursorValidation (now positions at end-of-input when clicked)
Claus Gittinger <cg@exept.de>
parents:
667
diff
changeset
|
1982 |
|
594 | 1983 |
leaveKeys isNil ifTrue:[ |
1984 |
leaveKeys := self class defaultLeaveKeys. |
|
1985 |
]. |
|
192 | 1986 |
cursorMovementWhenUpdating := #endOfLine |
594 | 1987 |
|
1937
b88111019826
added acceptOnPointerLeave - must be separate from acceptOnLeave
Claus Gittinger <cg@exept.de>
parents:
1936
diff
changeset
|
1988 |
"Modified: / 28.6.1999 / 18:08:17 / cg" |
192 | 1989 |
! ! |
1990 |
||
3702 | 1991 |
!EditField methodsFor:'menu actions'! |
1992 |
||
1993 |
editMenu |
|
1994 |
"return a popUpMenu for the receiver" |
|
1995 |
||
1996 |
<resource: #keyboard ( #Accept #Copy #Cut #Paste ) > |
|
1997 |
<resource: #programMenu> |
|
1998 |
||
4212 | 1999 |
|items m isReadOnly| |
2000 |
||
2001 |
isReadOnly := (self isReadOnly == true or:[enabled == false]). |
|
2002 |
isReadOnly ifTrue:[ |
|
3702 | 2003 |
items := #( |
2004 |
('Copy' copySelection Copy ) |
|
2005 |
) |
|
2006 |
] ifFalse:[ |
|
2007 |
items := #( |
|
2008 |
('Cut' cut Cut ) |
|
2009 |
('Copy' copySelection Copy ) |
|
2010 |
('Paste' pasteOrReplace Paste ) |
|
2011 |
). |
|
2012 |
(acceptAction notNil |
|
2013 |
or:[model notNil and:[changeMsg notNil]]) ifTrue:[ |
|
2014 |
immediateAccept ifFalse:[ |
|
2015 |
items := items , #( |
|
2016 |
('-' ) |
|
2017 |
('Accept' accept Accept) |
|
2018 |
). |
|
2019 |
]. |
|
2020 |
]. |
|
2021 |
]. |
|
2022 |
||
4992 | 2023 |
isReadOnly ifFalse:[ |
4194 | 2024 |
items := items , |
2025 |
#( |
|
2026 |
('-' ) |
|
4938 | 2027 |
('Insert Unicode...' insertUnicode ) |
4194 | 2028 |
). |
4938 | 2029 |
CharacterSetView notNil ifTrue:[ |
2030 |
items := items , |
|
2031 |
#( |
|
2032 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
2033 |
). |
|
2034 |
]. |
|
4194 | 2035 |
]. |
2036 |
||
3702 | 2037 |
m := PopUpMenu itemList:items resources:resources. |
2038 |
||
2039 |
passwordCharacter notNil ifTrue:[ |
|
2040 |
m disable:#copySelection |
|
2041 |
]. |
|
2042 |
||
2043 |
self hasSelectionForCopy ifFalse:[ |
|
2044 |
m disable:#copySelection |
|
2045 |
]. |
|
2046 |
self hasSelection ifFalse:[ |
|
2047 |
m disable:#cut |
|
2048 |
]. |
|
4212 | 2049 |
isReadOnly ifTrue:[ |
3702 | 2050 |
m disableAll:#(cut pasteOrReplace accept) |
2051 |
]. |
|
2052 |
||
2053 |
^ m |
|
2054 |
||
4212 | 2055 |
"Modified: / 17-01-2011 / 11:24:22 / cg" |
3702 | 2056 |
! ! |
2057 |
||
5122 | 2058 |
!EditField methodsFor:'native widget support'! |
2059 |
||
2060 |
nativeWindowType |
|
2061 |
"return a symbol describing my native window type |
|
2062 |
(may be used internally by the device as a native window creation hint)" |
|
2063 |
||
2064 |
^ #EditField |
|
2065 |
! ! |
|
2066 |
||
192 | 2067 |
!EditField methodsFor:'private'! |
2068 |
||
2069 |
argForChangeMessage |
|
2070 |
"redefined to send use converted value (if I have one)" |
|
2071 |
||
2538
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2072 |
|str| |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2073 |
|
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2074 |
str := self editValue. |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2075 |
(acceptIfUnchanged |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2076 |
and:[model notNil |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2077 |
and:[model value == self editValue]]) ifTrue:[ |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2078 |
"/ copy to force valueHolder to trigger |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2079 |
str := str copy. |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2080 |
]. |
ce313a0572e7
care for accept with unchangedValue;
Claus Gittinger <cg@exept.de>
parents:
2518
diff
changeset
|
2081 |
^ str |
192 | 2082 |
! |
2083 |
||
2084 |
getListFromModel |
|
2085 |
"redefined to aquire the text via the aspectMsg - not the listMsg, |
|
2086 |
and to ignore updates resulting from my own change." |
|
2087 |
||
1464 | 2088 |
|val| |
2089 |
||
192 | 2090 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
1464 | 2091 |
aspectMsg == #value ifTrue:[ |
2092 |
val := model value |
|
2093 |
] ifFalse:[ |
|
2094 |
val := model perform:aspectMsg |
|
2095 |
]. |
|
1503
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2096 |
|
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2097 |
" |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2098 |
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
|
2099 |
" |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2100 |
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
|
2101 |
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
|
2102 |
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
|
2103 |
^ self |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2104 |
] |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2105 |
]. |
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2106 |
|
1464 | 2107 |
self editValue:val. |
0 | 2108 |
] |
1464 | 2109 |
|
1503
ae953a367422
care for models ignoring a change (i.e. if doing range checks in
Claus Gittinger <cg@exept.de>
parents:
1482
diff
changeset
|
2110 |
"Modified: / 23.4.1998 / 10:10:37 / cg" |
0 | 2111 |
! |
2112 |
||
192 | 2113 |
startAutoScrollDown:y |
2114 |
"no vertical scrolling in editfields" |
|
2115 |
||
5095 | 2116 |
^ false |
192 | 2117 |
! |
2118 |
||
2119 |
startAutoScrollUp:y |
|
2120 |
"no vertical scrolling in editfields" |
|
2121 |
||
5095 | 2122 |
^ false |
192 | 2123 |
! |
0 | 2124 |
|
192 | 2125 |
textChanged |
2126 |
"this is sent by mySelf (somewhere in a superclass) whenever |
|
2127 |
my contents has changed. |
|
2128 |
A good place to add immediateAccept functionality and check for the |
|
2129 |
lengthLimit." |
|
2130 |
||
2131 |
|string c| |
|
2132 |
||
2133 |
super textChanged. |
|
2134 |
string := self contents. |
|
2135 |
lengthLimit notNil ifTrue:[ |
|
2136 |
string size > lengthLimit ifTrue:[ |
|
2137 |
c := cursorCol. |
|
2138 |
self contents:(string copyTo:lengthLimit). |
|
2139 |
self flash. |
|
2140 |
self cursorCol:c. |
|
125 | 2141 |
] |
0 | 2142 |
]. |
192 | 2143 |
immediateAccept ifTrue:[ |
2144 |
self accept |
|
2145 |
] |
|
105 | 2146 |
! |
2147 |
||
2616 | 2148 |
textChangedButNoSizeChange |
2296
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2149 |
"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
|
2150 |
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
|
2151 |
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
|
2152 |
|
2616 | 2153 |
super textChangedButNoSizeChange. |
2296
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2154 |
immediateAccept ifTrue:[ |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2155 |
self accept |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2156 |
] |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2157 |
! |
b924cc94580c
immediate update did not work for Backspace key (and some others)
Claus Gittinger <cg@exept.de>
parents:
2193
diff
changeset
|
2158 |
|
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2159 |
updateBackground |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2160 |
"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
|
2161 |
|
1974 | 2162 |
|fg| |
2163 |
||
3648
7a959d9db34f
dont (re)set the background, if I have a bg-channel.
Claus Gittinger <cg@exept.de>
parents:
3585
diff
changeset
|
2164 |
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
|
2165 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1683
diff
changeset
|
2166 |
(self isReadOnly or:[enabled not]) ifTrue:[ |
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2167 |
self backgroundColor:(View defaultViewBackgroundColor). |
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2168 |
enabled ifFalse:[ |
1974 | 2169 |
fg := StyleSheet colorAt:'editField.disabledForegroundColor' default:nil. |
2170 |
fg isNil ifTrue:[ |
|
2171 |
fg := StyleSheet colorAt:'button.disabledForegroundColor' default:Color gray. |
|
2172 |
]. |
|
2173 |
self foregroundColor:fg. |
|
3408 | 2174 |
] ifTrue:[ |
2175 |
self foregroundColor:DefaultForegroundColor. |
|
2176 |
]. |
|
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2177 |
] ifFalse:[ |
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2178 |
self backgroundColor:DefaultBackgroundColor. |
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2179 |
self foregroundColor:DefaultForegroundColor. |
1631
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2180 |
] |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2181 |
|
1632
01a7b330622a
change foregroundColor when disabled.
Claus Gittinger <cg@exept.de>
parents:
1631
diff
changeset
|
2182 |
"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
|
2183 |
! |
f8fae6670540
change viewBackground, when either disabled or readOnly.
Claus Gittinger <cg@exept.de>
parents:
1616
diff
changeset
|
2184 |
|
192 | 2185 |
visibleAt:visLineNr |
2186 |
"return the string at lineNr for display. |
|
2187 |
If there is a password character, return a string consisting of those only." |
|
2188 |
||
3988 | 2189 |
|s emptyText| |
105 | 2190 |
|
192 | 2191 |
s := super visibleAt:visLineNr. |
2192 |
passwordCharacter notNil ifTrue:[ |
|
3985 | 2193 |
^ String new:(s size) withAll:passwordCharacter |
192 | 2194 |
]. |
3985 | 2195 |
(s isEmptyOrNil |
3988 | 2196 |
and:[ (emptyText := self emptyFieldReplacementText) notNil |
3985 | 2197 |
and:[ self hasFocus not |
2198 |
and:[ visLineNr == 1 ]]]) |
|
2199 |
ifTrue:[ |
|
5098 | 2200 |
^ emptyText allItalic colorizeAllWith:Color lightGray. |
3985 | 2201 |
]. |
2202 |
||
192 | 2203 |
^ s |
2204 |
||
2205 |
"Modified: 6.9.1995 / 12:25:06 / claus" |
|
0 | 2206 |
! ! |
125 | 2207 |
|
192 | 2208 |
!EditField methodsFor:'queries'! |
2209 |
||
2350
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2349
diff
changeset
|
2210 |
hasSelectionForCopy |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2349
diff
changeset
|
2211 |
"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
|
2212 |
|
4992 | 2213 |
^ 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
|
2214 |
! |
c09d3dd534e3
do not allow copy of password-characters out of an editfield.
Claus Gittinger <cg@exept.de>
parents:
2349
diff
changeset
|
2215 |
|
561 | 2216 |
isInputField |
2217 |
"return true, if the receiver is some kind of input view, |
|
2218 |
i.e. it should (can) be part of an enterGroup. |
|
2219 |
Return true here" |
|
2220 |
||
2221 |
^ true |
|
2222 |
||
2223 |
"Created: 4.3.1996 / 11:32:34 / cg" |
|
2224 |
! |
|
2225 |
||
192 | 2226 |
preferredExtent |
2227 |
"return the preferred extent of this view. |
|
2228 |
That is the width of the string plus some extra, |
|
2229 |
but not wider than half of the screen" |
|
2230 |
||
1120 | 2231 |
|string w h f| |
125 | 2232 |
|
3768
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2233 |
"/ If I have an explicit preferredExtent.. |
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2234 |
explicitExtent notNil ifTrue:[ |
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2235 |
^ explicitExtent |
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2236 |
]. |
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2237 |
|
d759c921cb45
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3709
diff
changeset
|
2238 |
"/ If I have a cached preferredExtent value.. |
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
2239 |
preferredExtent notNil ifTrue:[ |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
2240 |
^ preferredExtent |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
2241 |
]. |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
2242 |
|
192 | 2243 |
string := self contents. |
2244 |
(string isNil or:[string isBlank]) ifTrue:[ |
|
4086 | 2245 |
w := fontWidth * 20. "space for 20 characters" |
2246 |
] ifFalse:[ |
|
2247 |
"length of current contents + 50% space to type more characters" |
|
4888 | 2248 |
f := gc font onDevice:self graphicsDevice. |
4086 | 2249 |
w := ((f widthOf:string) * 1.5) rounded. |
2250 |
w := w + margin + margin. |
|
192 | 2251 |
]. |
4888 | 2252 |
w := w min:(self graphicsDevice width // 2). |
667
d02f6bba8fc5
use fonts maxHeight in prefExtent (A-Umlaut)
Claus Gittinger <cg@exept.de>
parents:
660
diff
changeset
|
2253 |
|
3929 | 2254 |
"/ h := f maxHeight + (f maxDescent * 2) + (margin * 2). |
4086 | 2255 |
h := fontHeight + topMargin + (margin * 2). |
1120 | 2256 |
|
2257 |
^ w rounded @ h rounded |
|
192 | 2258 |
|
1542
5778dd813273
default height a bit larger (for caret cursors);
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
2259 |
"Modified: / 6.9.1995 / 19:24:06 / claus" |
5778dd813273
default height a bit larger (for caret cursors);
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
2260 |
"Modified: / 21.5.1998 / 02:13:35 / cg" |
192 | 2261 |
! |
2262 |
||
2263 |
specClass |
|
1372 | 2264 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditFieldSpec)" |
2265 |
||
192 | 2266 |
self class == EditField ifTrue:[^ InputFieldSpec]. |
1047 | 2267 |
^ super specClass |
125 | 2268 |
|
1372 | 2269 |
"Modified: / 5.9.1995 / 17:28:27 / claus" |
2270 |
"Modified: / 31.10.1997 / 19:48:59 / cg" |
|
325 | 2271 |
! |
2272 |
||
2273 |
tabMeansNextField |
|
2274 |
"return true, if Tab character should shift focus to the next field" |
|
2275 |
||
2276 |
"if I have a completionBlock, I want my Tabs ..." |
|
2277 |
||
2993 | 2278 |
^ self entryCompletionBlock isNil or:[entryCompletionCharacter ~~ #Tab] |
325 | 2279 |
|
2280 |
"Created: 7.2.1996 / 19:16:38 / cg" |
|
192 | 2281 |
! ! |
2282 |
||
2283 |
!EditField methodsFor:'realization'! |
|
2284 |
||
1274 | 2285 |
realize |
192 | 2286 |
"scroll back to beginning when realized" |
1268 | 2287 |
|
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
2288 |
viewOrigin := 0 @ viewOrigin y. |
1274 | 2289 |
super realize |
1268 | 2290 |
|
1274 | 2291 |
"Created: 24.7.1997 / 18:23:15 / cg" |
125 | 2292 |
! ! |
192 | 2293 |
|
2294 |
!EditField methodsFor:'scrolling'! |
|
2295 |
||
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2296 |
makeColVisible:col inLine:lineNr |
4157
7f2928f99268
comment/format in: #makeColVisible:inLine:
Claus Gittinger <cg@exept.de>
parents:
4118
diff
changeset
|
2297 |
"don't scroll for the cursor, if its beyond the text and a lengthLimit |
192 | 2298 |
is present." |
2299 |
||
2759 | 2300 |
|wText innerWidth colToMakeVisible| |
2424 | 2301 |
|
2302 |
innerWidth := self innerWidth. |
|
2759 | 2303 |
colToMakeVisible := col. |
2016
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2304 |
|
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2305 |
lengthLimit notNil ifTrue:[ |
2424 | 2306 |
(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
|
2307 |
ifTrue:[ |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2308 |
^ self |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2309 |
]. |
2424 | 2310 |
(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
|
2311 |
ifTrue:[ |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2312 |
^ self |
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2313 |
]. |
2759 | 2314 |
(col == cursorCol and:[col > lengthLimit]) ifTrue:[ |
2315 |
colToMakeVisible := lengthLimit |
|
2016
7a4d89c99c98
dont scroll horizontally, if there is a lengthLimit,
Claus Gittinger <cg@exept.de>
parents:
1999
diff
changeset
|
2316 |
]. |
192 | 2317 |
]. |
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2318 |
|
2759 | 2319 |
super makeColVisible:colToMakeVisible inLine:lineNr. |
2320 |
||
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2321 |
"/ new: |
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2322 |
"/ care to make the most possible visible |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2425
diff
changeset
|
2323 |
viewOrigin x > 0 ifTrue:[ |
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2324 |
wText := self widthOfLine:lineNr. |
2424 | 2325 |
wText <= innerWidth ifTrue:[ |
1751
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2326 |
self scrollHorizontalTo:0 |
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2327 |
] |
f29c3312beaf
adjust h-scroll offset if only part is visible,
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
2328 |
] |
192 | 2329 |
|
4157
7f2928f99268
comment/format in: #makeColVisible:inLine:
Claus Gittinger <cg@exept.de>
parents:
4118
diff
changeset
|
2330 |
"Modified: / 06-09-1995 / 13:57:53 / claus" |
7f2928f99268
comment/format in: #makeColVisible:inLine:
Claus Gittinger <cg@exept.de>
parents:
4118
diff
changeset
|
2331 |
"Modified: / 04-08-2010 / 17:30:17 / cg" |
192 | 2332 |
! ! |
2333 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2334 |
!EditField methodsFor:'selections'! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2335 |
|
3366
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2336 |
copySelection |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2337 |
"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
|
2338 |
|
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2339 |
passwordCharacter notNil ifTrue:[ |
3367 | 2340 |
self beep. |
3366
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2341 |
^ self |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2342 |
]. |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2343 |
^ super copySelection |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2344 |
! |
0df1eb5da5aa
refuse to copy passwords to the clipboard.
Claus Gittinger <cg@exept.de>
parents:
3305
diff
changeset
|
2345 |
|
1080
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2346 |
selectAll |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2347 |
"select the whole text. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2348 |
redefined to send super selectFrom... since we dont want the |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2349 |
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
|
2350 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2351 |
|len| |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2352 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2353 |
list isNil ifTrue:[ |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2354 |
self unselect |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2355 |
] ifFalse:[ |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2356 |
len := (self listAt:1) size. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2357 |
len ~~ 0 ifTrue:[ |
4992 | 2358 |
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
|
2359 |
]. |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2360 |
typeOfSelection := nil |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2361 |
] |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2362 |
|
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2363 |
"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
|
2364 |
! |
73877901fa7d
redefined #selectAll to select nothing if there is nothing
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
2365 |
|
4540 | 2366 |
selectFrom:firstColToSelect |
2367 |
"select the right part of the text" |
|
2368 |
||
2369 |
|len| |
|
2370 |
||
2371 |
list isNil ifTrue:[ |
|
2372 |
self unselect |
|
2373 |
] ifFalse:[ |
|
2374 |
len := (self listAt:1) size. |
|
2375 |
firstColToSelect <= len ifTrue:[ |
|
2376 |
self selectFromLine:1 col:firstColToSelect toLine:1 col:len. |
|
2377 |
]. |
|
2378 |
typeOfSelection := nil |
|
2379 |
] |
|
2380 |
! |
|
2381 |
||
5041 | 2382 |
setClipboardText:something |
2383 |
"redefined to refuse to copy the password to the clipboard" |
|
2384 |
||
2385 |
passwordCharacter notNil ifTrue:[ |
|
2386 |
self beep. |
|
2387 |
^ self |
|
2388 |
]. |
|
2389 |
^ super setClipboardText:something |
|
2390 |
! |
|
2391 |
||
5042 | 2392 |
setLastStringToReplace: sel |
2393 |
"redefined to refuse to remember the password" |
|
2394 |
||
2395 |
passwordCharacter notNil ifTrue:[ |
|
2396 |
^ self |
|
2397 |
]. |
|
2398 |
^ super setLastStringToReplace: sel |
|
2399 |
! |
|
2400 |
||
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2401 |
validateNewSelection |
1654 | 2402 |
"make certain that only one line is ever selected" |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2403 |
|
1654 | 2404 |
selectionEndLine notNil ifTrue:[ |
2405 |
selectionEndLine > 1 ifTrue:[ |
|
2406 |
selectionEndLine := 2. selectionEndCol := 0 |
|
2407 |
] |
|
2408 |
]. |
|
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2409 |
! ! |
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2410 |
|
892 | 2411 |
!EditField class methodsFor:'documentation'! |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2412 |
|
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2413 |
version |
5240 | 2414 |
^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.244 2015-01-12 10:30:14 cg Exp $' |
3975
73674d16fc63
copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
2415 |
! |
73674d16fc63
copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
2416 |
|
73674d16fc63
copy asOrderedCollection -> copyAsOrderedCollection
Claus Gittinger <cg@exept.de>
parents:
3929
diff
changeset
|
2417 |
version_CVS |
5240 | 2418 |
^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.244 2015-01-12 10:30:14 cg Exp $' |
261
afcea54bd74e
added channel-enable (needs overall cleanup)
Claus Gittinger <cg@exept.de>
parents:
258
diff
changeset
|
2419 |
! ! |
4507 | 2420 |