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