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 |
"
|
|
12 |
|
125
|
13 |
'From Smalltalk/X, Version:2.10.5 on 9-may-1995 at 12:09:38 pm'!
|
105
|
14 |
|
0
|
15 |
EditTextView subclass:#EditField
|
125
|
16 |
instanceVariableNames:'leaveAction enabled enableAction crAction tabAction converter
|
127
|
17 |
leaveKeys immediateAccept acceptOnLeave acceptOnReturn
|
187
|
18 |
lengthLimit entryCompletionBlock passwordCharacter cursorMovementWhenUpdating'
|
105
|
19 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
|
127
|
20 |
DefaultSelectionForegroundColor DefaultSelectionBackgroundColor
|
|
21 |
DefaultFont'
|
105
|
22 |
poolDictionaries:''
|
|
23 |
category:'Views-Text'
|
0
|
24 |
!
|
|
25 |
|
19
|
26 |
!EditField class methodsFor:'documentation'!
|
|
27 |
|
38
|
28 |
copyright
|
|
29 |
"
|
|
30 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
59
|
31 |
All Rights Reserved
|
38
|
32 |
|
|
33 |
This software is furnished under a license and may be used
|
|
34 |
only in accordance with the terms of that license and with the
|
|
35 |
inclusion of the above copyright notice. This software may not
|
|
36 |
be provided or otherwise made available to, or used by, any
|
|
37 |
other person. No title to or ownership of the software is
|
|
38 |
hereby transferred.
|
|
39 |
"
|
|
40 |
!
|
|
41 |
|
|
42 |
version
|
187
|
43 |
^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.31 1995-11-20 16:11:27 cg Exp $'
|
38
|
44 |
!
|
|
45 |
|
19
|
46 |
documentation
|
|
47 |
"
|
38
|
48 |
an editable text-field. Realized by using an EditTextView,
|
|
49 |
and forcing its size to 1 line - disabling cursor movement
|
|
50 |
in the vertical direction.
|
121
|
51 |
|
|
52 |
Instance variables:
|
|
53 |
|
|
54 |
leaveAction <Block | nil> if non-nil, this is evaluated with
|
|
55 |
the key (#Return, #CursorUp etc.) when
|
|
56 |
the field is left via keyboard keys.
|
|
57 |
(fieldGroups use this to decide which
|
|
58 |
field has to be enabled next)
|
|
59 |
|
|
60 |
enabled <Boolean> if false, input is ignored.
|
|
61 |
|
125
|
62 |
enableAction <Block | nil> action performed if the field is
|
|
63 |
enabled via an explicit click.
|
|
64 |
(this is used by the group to
|
|
65 |
set the active field to the clicked upon field)
|
121
|
66 |
|
|
67 |
crAction <Block | nil> if non-nil, keyboard input of a cr are not
|
|
68 |
handled specially, instead this block is evaluated
|
|
69 |
(however, this block can perform additional checks and send
|
|
70 |
a #accept then)
|
|
71 |
|
|
72 |
tabAction <Block | nil> if non-nil, keyboard input of a tab character
|
|
73 |
is not entered into the text, instead this block
|
|
74 |
is evaluated.
|
|
75 |
|
|
76 |
converter <PrintConverter | nil> if non-nil, this is supposed to convert between
|
|
77 |
the object and its printed representation.
|
|
78 |
Defaults to nil i.e. assume that strings are edited.
|
|
79 |
|
|
80 |
leaveKeys <Collection> keys which are interpreted as 'leving the field'
|
122
|
81 |
|
125
|
82 |
immediateAccept <Boolean> if true, every change of the text is immediately
|
|
83 |
forwarded to the model/acceptBlock. If false,
|
|
84 |
the changed value is only stored in the model
|
|
85 |
if the field is left or accepted.
|
|
86 |
Default is false.
|
122
|
87 |
|
|
88 |
acceptOnLeave <Boolean> if true, leaving the field (via cursor keys)
|
|
89 |
automatically accepts the value into the model.
|
130
|
90 |
Default is true.
|
122
|
91 |
|
|
92 |
acceptOnReturn <Boolean> if true, leaving the field via return
|
|
93 |
automatically accepts the value into the model.
|
130
|
94 |
Default is true.
|
19
|
95 |
"
|
120
|
96 |
!
|
|
97 |
|
|
98 |
examples
|
|
99 |
"
|
122
|
100 |
see more examples in EnterFieldGroup>>examples.
|
|
101 |
|
|
102 |
|
|
103 |
basic field in a view:
|
120
|
104 |
|
|
105 |
|top field|
|
|
106 |
|
|
107 |
top := StandardSystemView new.
|
|
108 |
top extent:200@100.
|
|
109 |
|
|
110 |
field := EditField origin:0.0@0.0 in:top.
|
|
111 |
field width:1.0. 'let its height as-is'.
|
|
112 |
|
|
113 |
top open
|
|
114 |
|
122
|
115 |
|
125
|
116 |
forward input in topView to the field:
|
|
117 |
(currently, the field does not know this - therefore,
|
|
118 |
its been told here ... this may change)
|
122
|
119 |
|
|
120 |
|top field|
|
|
121 |
|
|
122 |
top := StandardSystemView new.
|
|
123 |
top extent:200@100.
|
|
124 |
|
|
125 |
field := EditField origin:0.0@0.0 in:top.
|
|
126 |
field width:1.0. 'let its height as-is'.
|
|
127 |
|
|
128 |
top delegate:(KeyboardForwarder toView:field).
|
125
|
129 |
field hasKeyboardFocus:true.
|
122
|
130 |
top open
|
|
131 |
|
|
132 |
|
125
|
133 |
to make it look better: set some inset:
|
120
|
134 |
|
|
135 |
|top field|
|
|
136 |
|
|
137 |
top := StandardSystemView new.
|
|
138 |
top extent:200@100.
|
|
139 |
|
|
140 |
field := EditField origin:0.0@ViewSpacing in:top.
|
|
141 |
field width:1.0. 'let its height as-is'.
|
|
142 |
field leftInset:ViewSpacing;
|
|
143 |
rightInset:ViewSpacing.
|
|
144 |
|
|
145 |
top open
|
|
146 |
|
122
|
147 |
|
120
|
148 |
give it an initial contents:
|
|
149 |
|
|
150 |
|top field|
|
|
151 |
|
|
152 |
top := StandardSystemView new.
|
|
153 |
top extent:200@100.
|
|
154 |
|
|
155 |
field := EditField origin:0.0@ViewSpacing in:top.
|
|
156 |
field width:1.0.
|
|
157 |
field leftInset:ViewSpacing;
|
|
158 |
rightInset:ViewSpacing.
|
121
|
159 |
field editValue:'hello world'.
|
120
|
160 |
|
|
161 |
top open
|
|
162 |
|
122
|
163 |
|
125
|
164 |
have it preselected:
|
120
|
165 |
|
|
166 |
|top field|
|
|
167 |
|
|
168 |
top := StandardSystemView new.
|
|
169 |
top extent:200@100.
|
|
170 |
|
|
171 |
field := EditField origin:0.0@ViewSpacing in:top.
|
|
172 |
field width:1.0.
|
|
173 |
field leftInset:ViewSpacing;
|
|
174 |
rightInset:ViewSpacing.
|
121
|
175 |
field editValue:'hello world' selected:true.
|
120
|
176 |
|
|
177 |
top open
|
|
178 |
|
122
|
179 |
|
120
|
180 |
have part of it preselected:
|
|
181 |
|
|
182 |
|top field|
|
|
183 |
|
|
184 |
top := StandardSystemView new.
|
|
185 |
top extent:200@100.
|
|
186 |
|
|
187 |
field := EditField origin:0.0@ViewSpacing in:top.
|
|
188 |
field width:1.0.
|
|
189 |
field leftInset:ViewSpacing;
|
|
190 |
rightInset:ViewSpacing.
|
121
|
191 |
field editValue:'hello world';
|
120
|
192 |
selectFromCharacterPosition:1 to:5.
|
|
193 |
|
|
194 |
top open
|
|
195 |
|
122
|
196 |
|
125
|
197 |
set a size limit:
|
|
198 |
|
|
199 |
|top field|
|
|
200 |
|
|
201 |
top := StandardSystemView new.
|
|
202 |
top extent:200@100.
|
|
203 |
|
|
204 |
field := EditField origin:0.0@ViewSpacing in:top.
|
|
205 |
field width:1.0.
|
|
206 |
field leftInset:ViewSpacing;
|
|
207 |
rightInset:ViewSpacing.
|
|
208 |
field editValue:'hello';
|
|
209 |
maxChars:8.
|
|
210 |
|
|
211 |
top open
|
|
212 |
|
|
213 |
|
121
|
214 |
use a converter:
|
125
|
215 |
- numbers (default to 0):
|
121
|
216 |
|
|
217 |
|top field|
|
|
218 |
|
|
219 |
top := StandardSystemView new.
|
|
220 |
top extent:200@100.
|
|
221 |
|
|
222 |
field := EditField origin:0.0@ViewSpacing in:top.
|
|
223 |
field width:1.0.
|
|
224 |
field leftInset:ViewSpacing;
|
|
225 |
rightInset:ViewSpacing.
|
|
226 |
|
|
227 |
field converter:(PrintConverter new initForNumber).
|
|
228 |
field editValue:1234.
|
|
229 |
field acceptAction:[:value | Transcript showCr:value].
|
|
230 |
field crAction:[field accept. top destroy].
|
|
231 |
top open.
|
|
232 |
|
|
233 |
- dates:
|
|
234 |
|
|
235 |
|top field|
|
|
236 |
|
|
237 |
top := StandardSystemView new.
|
|
238 |
top extent:200@100.
|
|
239 |
|
|
240 |
field := EditField origin:0.0@ViewSpacing in:top.
|
|
241 |
field width:1.0.
|
|
242 |
field leftInset:ViewSpacing;
|
|
243 |
rightInset:ViewSpacing.
|
|
244 |
|
|
245 |
field converter:(PrintConverter new initForDate).
|
|
246 |
field editValue:Date today.
|
125
|
247 |
field acceptAction:[:value | Transcript showCr:value class name , ' ' , value printString].
|
121
|
248 |
field crAction:[field accept. top destroy].
|
|
249 |
top open.
|
|
250 |
|
122
|
251 |
|
125
|
252 |
setting immediateAccept, makes the field update with every key:
|
|
253 |
|
|
254 |
- immediate accept numbers, defaulting to nil:
|
121
|
255 |
|
|
256 |
|top field|
|
|
257 |
|
|
258 |
top := StandardSystemView new.
|
|
259 |
top extent:200@100.
|
|
260 |
|
|
261 |
field := EditField origin:0.0@ViewSpacing in:top.
|
|
262 |
field width:1.0.
|
|
263 |
field leftInset:ViewSpacing;
|
|
264 |
rightInset:ViewSpacing.
|
|
265 |
|
125
|
266 |
field converter:(PrintConverter new initForNumberOrNil).
|
|
267 |
field immediateAccept:true.
|
121
|
268 |
field editValue:1234.
|
|
269 |
field acceptAction:[:value | Transcript showCr:value].
|
|
270 |
field crAction:[field accept. top destroy].
|
|
271 |
top open.
|
|
272 |
|
122
|
273 |
|
127
|
274 |
|
|
275 |
|
120
|
276 |
use a model:
|
|
277 |
(see changing model value in inspector when return is pressed in the field)
|
|
278 |
|
|
279 |
|top field model|
|
|
280 |
|
|
281 |
model := 'hello world' asValue.
|
|
282 |
|
|
283 |
top := StandardSystemView new.
|
|
284 |
top extent:200@100.
|
|
285 |
|
|
286 |
field := EditField origin:0.0@ViewSpacing in:top.
|
121
|
287 |
field width:1.0.
|
120
|
288 |
field leftInset:ViewSpacing;
|
|
289 |
rightInset:ViewSpacing.
|
|
290 |
field model:model.
|
128
|
291 |
field acceptOnReturn:true.
|
120
|
292 |
|
|
293 |
top open.
|
121
|
294 |
model inspect.
|
|
295 |
|
122
|
296 |
|
127
|
297 |
two views on the same model (each accepts on return):
|
121
|
298 |
|
|
299 |
|top1 top2 field1 field2 model|
|
|
300 |
|
|
301 |
model := 'hello world' asValue.
|
|
302 |
|
|
303 |
top1 := StandardSystemView new.
|
|
304 |
top1 extent:200@100.
|
|
305 |
field1 := EditField origin:0.0@ViewSpacing in:top1.
|
|
306 |
field1 width:1.0.
|
|
307 |
field1 leftInset:ViewSpacing;
|
|
308 |
rightInset:ViewSpacing.
|
|
309 |
field1 model:model.
|
128
|
310 |
field1 acceptOnReturn:true.
|
121
|
311 |
top1 open.
|
|
312 |
|
|
313 |
top2 := StandardSystemView new.
|
|
314 |
top2 extent:200@100.
|
|
315 |
field2 := EditField origin:0.0@ViewSpacing in:top2.
|
|
316 |
field2 width:1.0.
|
|
317 |
field2 leftInset:ViewSpacing;
|
|
318 |
rightInset:ViewSpacing.
|
|
319 |
field2 model:model.
|
128
|
320 |
field2 acceptOnReturn:true.
|
121
|
321 |
top2 open.
|
|
322 |
|
127
|
323 |
two views on the same model (no accept on return):
|
|
324 |
|
|
325 |
|top1 top2 field1 field2 model|
|
|
326 |
|
|
327 |
model := 'hello world' asValue.
|
|
328 |
|
|
329 |
top1 := StandardSystemView new.
|
|
330 |
top1 extent:200@100.
|
|
331 |
field1 := EditField origin:0.0@ViewSpacing in:top1.
|
|
332 |
field1 width:1.0.
|
|
333 |
field1 leftInset:ViewSpacing;
|
|
334 |
rightInset:ViewSpacing.
|
|
335 |
field1 model:model; acceptOnReturn:false.
|
|
336 |
top1 open.
|
|
337 |
|
|
338 |
top2 := StandardSystemView new.
|
|
339 |
top2 extent:200@100.
|
|
340 |
field2 := EditField origin:0.0@ViewSpacing in:top2.
|
|
341 |
field2 width:1.0.
|
|
342 |
field2 leftInset:ViewSpacing;
|
|
343 |
rightInset:ViewSpacing.
|
|
344 |
field2 model:model; acceptOnReturn:false.
|
|
345 |
top2 open.
|
|
346 |
|
125
|
347 |
with immediate accept:
|
|
348 |
|
|
349 |
|top1 top2 field1 field2 model|
|
|
350 |
|
|
351 |
model := 'hello world' asValue.
|
|
352 |
|
|
353 |
top1 := StandardSystemView new.
|
|
354 |
top1 extent:200@100.
|
|
355 |
field1 := EditField origin:0.0@ViewSpacing in:top1.
|
|
356 |
field1 width:1.0.
|
|
357 |
field1 leftInset:ViewSpacing; rightInset:ViewSpacing.
|
|
358 |
field1 model:model; immediateAccept:true.
|
|
359 |
top1 open.
|
|
360 |
|
|
361 |
top2 := StandardSystemView new.
|
|
362 |
top2 extent:200@100.
|
|
363 |
field2 := EditField origin:0.0@ViewSpacing in:top2.
|
|
364 |
field2 width:1.0.
|
|
365 |
field2 leftInset:ViewSpacing; rightInset:ViewSpacing.
|
|
366 |
field2 model:model; immediateAccept:true.
|
|
367 |
top2 open.
|
122
|
368 |
|
121
|
369 |
just an example; a checkBox and an editField on the same model:
|
|
370 |
|
|
371 |
|top1 top2 field1 box model|
|
|
372 |
|
|
373 |
model := false asValue.
|
|
374 |
|
|
375 |
top1 := StandardSystemView new.
|
|
376 |
top1 extent:200@100.
|
|
377 |
field1 := EditField origin:0.0@ViewSpacing in:top1.
|
|
378 |
field1 width:1.0.
|
|
379 |
field1 leftInset:ViewSpacing;
|
|
380 |
rightInset:ViewSpacing.
|
|
381 |
field1 converter:(PrintConverter new initForYesNo).
|
|
382 |
field1 model:model.
|
|
383 |
top1 open.
|
|
384 |
|
|
385 |
top2 := StandardSystemView new.
|
|
386 |
top2 extent:200@100.
|
|
387 |
box := CheckBox on:model.
|
|
388 |
box label:'on/off'.
|
|
389 |
top2 add:box.
|
|
390 |
top2 open.
|
|
391 |
|
120
|
392 |
model inspect.
|
125
|
393 |
|
|
394 |
|
|
395 |
connecting fields:
|
|
396 |
update field2 wehenever field1 is changed.
|
|
397 |
(normally, the processing below (xChanged) is done in your application
|
|
398 |
class, or in a complex model. For the demonstration below, we use
|
|
399 |
a Plug to simulate the protocol.)
|
|
400 |
|
|
401 |
|application top field1 field2 value1 value2|
|
|
402 |
|
|
403 |
application := Plug new.
|
|
404 |
application respondTo:#value1Changed
|
|
405 |
with:[value2 value:(value1 value isNil ifTrue:[nil]
|
|
406 |
ifFalse:[value1 value squared])].
|
|
407 |
|
|
408 |
value1 := 1 asValue.
|
|
409 |
value2 := 1 asValue.
|
|
410 |
|
|
411 |
top := Dialog new.
|
|
412 |
top extent:200@200.
|
|
413 |
|
|
414 |
(top addTextLabel:'some number:') layout:#left.
|
|
415 |
top addVerticalSpace.
|
|
416 |
|
|
417 |
(top addInputFieldOn:value1 tabable:false)
|
|
418 |
converter:(PrintConverter new initForNumberOrNil);
|
|
419 |
immediateAccept:true.
|
|
420 |
top addVerticalSpace.
|
|
421 |
|
|
422 |
(top addTextLabel:'squared:') layout:#left.
|
|
423 |
top addVerticalSpace.
|
|
424 |
(top addInputFieldOn:value2 tabable:false)
|
|
425 |
converter:(PrintConverter new initForNumberOrNil).
|
|
426 |
|
|
427 |
value1 onChangeSend:#value1Changed to:application.
|
|
428 |
|
|
429 |
top openModeless.
|
|
430 |
|
|
431 |
|
|
432 |
two-way connect:
|
|
433 |
each field updates the other (notice, that we have to turn off
|
|
434 |
onChange: notification, to avoid an endless notification cycle)
|
|
435 |
|
|
436 |
|application top field1 field2 value1 value2|
|
|
437 |
|
|
438 |
application := Plug new.
|
|
439 |
application respondTo:#value1Changed
|
|
440 |
with:[value2 retractInterrestFor:application.
|
|
441 |
value2 value:(value1 value isNil ifTrue:[nil]
|
|
442 |
ifFalse:[value1 value squared]).
|
|
443 |
value2 onChangeSend:#value2Changed to:application.
|
|
444 |
].
|
|
445 |
application respondTo:#value2Changed
|
|
446 |
with:[value1 retractInterrestFor:application.
|
|
447 |
value1 value:(value2 value isNil ifTrue:[nil]
|
|
448 |
ifFalse:[value2 value sqrt]).
|
|
449 |
value1 onChangeSend:#value1Changed to:application.
|
|
450 |
].
|
|
451 |
|
|
452 |
value1 := 1 asValue.
|
|
453 |
value2 := 1 asValue.
|
|
454 |
|
|
455 |
top := Dialog new.
|
|
456 |
top extent:200@200.
|
|
457 |
|
|
458 |
(top addTextLabel:'some number:') layout:#left.
|
|
459 |
top addVerticalSpace.
|
|
460 |
|
|
461 |
(top addInputFieldOn:value1 tabable:false)
|
|
462 |
converter:(PrintConverter new initForNumberOrNil);
|
|
463 |
immediateAccept:true.
|
|
464 |
top addVerticalSpace.
|
|
465 |
|
|
466 |
(top addTextLabel:'squared:') layout:#left.
|
|
467 |
top addVerticalSpace.
|
|
468 |
(top addInputFieldOn:value2 tabable:false)
|
127
|
469 |
converter:(PrintConverter new initForNumberOrNil);
|
|
470 |
immediateAccept:true.
|
125
|
471 |
|
|
472 |
value1 onChangeSend:#value1Changed to:application.
|
|
473 |
value2 onChangeSend:#value2Changed to:application.
|
|
474 |
|
|
475 |
top openModeless.
|
120
|
476 |
"
|
19
|
477 |
! !
|
0
|
478 |
|
|
479 |
!EditField class methodsFor:'defaults'!
|
|
480 |
|
125
|
481 |
defaultLeaveKeys
|
128
|
482 |
"return the set of keys which are taken as leave-keys.
|
|
483 |
If the field is in an enterFieldGroup, all leave keys will be
|
|
484 |
forwarded to the group and possible step to the next/previous field.
|
|
485 |
Also, if acceptOnLeave is true, leave keys will store the current
|
|
486 |
value into their model (if any)"
|
|
487 |
|
125
|
488 |
^ #(Return CursorUp CursorDown Next Previous Accept)
|
|
489 |
!
|
|
490 |
|
59
|
491 |
updateStyleCache
|
60
|
492 |
DefaultForegroundColor := StyleSheet colorAt:'editFieldForegroundColor' default:Black.
|
|
493 |
DefaultBackgroundColor := StyleSheet colorAt:'editFieldBackgroundColor' default:White.
|
|
494 |
DefaultSelectionForegroundColor := StyleSheet colorAt:'editFieldSelectionForegroundColor' default:DefaultBackgroundColor.
|
|
495 |
DefaultSelectionBackgroundColor := StyleSheet colorAt:'editFieldSelectionBackgroundColor' default:DefaultForegroundColor.
|
|
496 |
DefaultFont := StyleSheet fontAt:'editFieldFont' default:nil.
|
59
|
497 |
|
|
498 |
"
|
60
|
499 |
self updateStyleCache
|
59
|
500 |
"
|
105
|
501 |
!
|
|
502 |
|
|
503 |
defaultNumberOfLines
|
|
504 |
"the number of lines in the field"
|
|
505 |
|
|
506 |
^ 1
|
0
|
507 |
! !
|
|
508 |
|
125
|
509 |
!EditField methodsFor:'private'!
|
|
510 |
|
|
511 |
textChanged
|
|
512 |
"this is sent by mySelf (somewhere in a superclass) whenever
|
|
513 |
my contents has changed.
|
|
514 |
A good place to add immediateAccept functionality and check for the
|
|
515 |
lengthLimit."
|
|
516 |
|
155
|
517 |
|string c|
|
125
|
518 |
|
|
519 |
super textChanged.
|
|
520 |
string := self contents.
|
|
521 |
lengthLimit notNil ifTrue:[
|
|
522 |
string size > lengthLimit ifTrue:[
|
155
|
523 |
c := cursorCol.
|
|
524 |
self contents:(string copyTo:lengthLimit).
|
125
|
525 |
self flash.
|
155
|
526 |
self cursorCol:c.
|
125
|
527 |
]
|
|
528 |
].
|
|
529 |
immediateAccept ifTrue:[
|
|
530 |
self accept
|
|
531 |
]
|
|
532 |
!
|
|
533 |
|
|
534 |
getListFromModel
|
|
535 |
"redefined to aquire the text via the aspectMsg - not the listMsg,
|
|
536 |
and to ignore updates resulting from my own change."
|
|
537 |
|
|
538 |
"
|
|
539 |
ignore updates from my own change
|
|
540 |
"
|
|
541 |
lockUpdates ifTrue:[
|
|
542 |
lockUpdates := false.
|
|
543 |
^ self
|
|
544 |
].
|
|
545 |
|
|
546 |
(model notNil and:[aspectMsg notNil]) ifTrue:[
|
|
547 |
self editValue:(model perform:aspectMsg).
|
|
548 |
]
|
|
549 |
!
|
|
550 |
|
127
|
551 |
argForChangeMessage
|
|
552 |
"redefined to send use converted value (if I have one)"
|
|
553 |
|
|
554 |
^ self editValue
|
|
555 |
!
|
|
556 |
|
125
|
557 |
startAutoScrollUp:y
|
|
558 |
"no vertical scrolling in editfields"
|
|
559 |
|
|
560 |
^ self
|
|
561 |
!
|
|
562 |
|
155
|
563 |
visibleAt:visLineNr
|
|
564 |
"return the string at lineNr for display.
|
|
565 |
If there is a password character, return a string consisting of those only."
|
|
566 |
|
|
567 |
|s|
|
|
568 |
|
|
569 |
s := super visibleAt:visLineNr.
|
|
570 |
passwordCharacter notNil ifTrue:[
|
|
571 |
^ String new:(s size) withAll:passwordCharacter
|
|
572 |
].
|
|
573 |
^ s
|
|
574 |
|
|
575 |
"Modified: 6.9.1995 / 12:25:06 / claus"
|
|
576 |
!
|
|
577 |
|
125
|
578 |
startAutoScrollDown:y
|
|
579 |
"no vertical scrolling in editfields"
|
|
580 |
|
|
581 |
^ self
|
|
582 |
! !
|
|
583 |
|
155
|
584 |
!EditField methodsFor:'scrolling'!
|
|
585 |
|
|
586 |
makeColVisible:col inLine:line
|
|
587 |
"dont scroll for the cursor, if its behond the text and a lengthLimit
|
|
588 |
is present."
|
|
589 |
|
|
590 |
lengthLimit notNil ifTrue:[
|
|
591 |
(col == cursorCol and:[col > lengthLimit]) ifTrue:[
|
|
592 |
^ super makeColVisible:lengthLimit inLine:line
|
|
593 |
]
|
|
594 |
].
|
|
595 |
^ super makeColVisible:col inLine:line
|
|
596 |
|
|
597 |
"Modified: 6.9.1995 / 13:57:53 / claus"
|
187
|
598 |
! !
|
125
|
599 |
|
187
|
600 |
!EditField methodsFor:'accessing-contents'!
|
125
|
601 |
|
|
602 |
list:someText
|
187
|
603 |
"low level access to the underlying contents' list.
|
|
604 |
Redefined to force text to 1 line, and notify dependents
|
|
605 |
of any changed extent-wishes (for automatic box resizing)."
|
125
|
606 |
|
|
607 |
|l oldWidth|
|
|
608 |
|
|
609 |
l := someText.
|
|
610 |
l size > 1 ifTrue:[
|
|
611 |
l := OrderedCollection with:(l at:1)
|
|
612 |
].
|
|
613 |
oldWidth := self widthOfContents.
|
|
614 |
super list:l.
|
|
615 |
self widthOfContents ~~ oldWidth ifTrue:[
|
130
|
616 |
self changed:#preferredExtent
|
125
|
617 |
]
|
|
618 |
!
|
|
619 |
|
187
|
620 |
contents
|
|
621 |
"return contents as a string
|
|
622 |
- redefined since EditFields hold only one line of text.
|
|
623 |
In your application, please use #editValue;
|
|
624 |
it uses a converter (if any) and is compatible to ST-80."
|
|
625 |
|
|
626 |
list isNil ifTrue:[^ ''].
|
|
627 |
(list size == 0) ifTrue:[^ ''].
|
|
628 |
^ list at:1
|
|
629 |
!
|
|
630 |
|
125
|
631 |
contents:someText
|
|
632 |
"set the contents from a string
|
|
633 |
- redefined to place the cursor to the end.
|
|
634 |
In your application, please use #editValue:;
|
|
635 |
it uses a converter (if any) and is compatible to ST-80."
|
|
636 |
|
187
|
637 |
|newCol|
|
|
638 |
|
|
639 |
newCol := cursorCol.
|
|
640 |
|
125
|
641 |
super contents:someText.
|
|
642 |
|
187
|
643 |
cursorMovementWhenUpdating == #endOfLine ifTrue:[
|
|
644 |
newCol := (someText size + 1).
|
|
645 |
] ifFalse:[
|
|
646 |
cursorMovementWhenUpdating == #beginOfLine ifTrue:[
|
|
647 |
newCol := 1
|
|
648 |
] ifFalse:[
|
|
649 |
"/ default: stay where it was
|
|
650 |
]
|
|
651 |
].
|
125
|
652 |
|
187
|
653 |
self cursorCol:newCol.
|
125
|
654 |
!
|
|
655 |
|
|
656 |
editValue
|
|
657 |
"if the field edits a string, this is a name alias for #contents.
|
|
658 |
Otherwise, if there is a converter, return the edited string
|
|
659 |
converted to an appropriate object."
|
|
660 |
|
|
661 |
|string|
|
|
662 |
|
|
663 |
string := self contents.
|
|
664 |
converter isNil ifTrue:[^ string].
|
|
665 |
string isNil ifTrue:[string := ''].
|
|
666 |
^ converter readValueFrom:string
|
|
667 |
!
|
0
|
668 |
|
125
|
669 |
editValue:aStringOrObject
|
|
670 |
"set the contents. If there is a converter, use it to convert
|
|
671 |
the object into a printed representation.
|
|
672 |
Otherwise, the argument is supposed to be a string like object,
|
|
673 |
and used directly (i.e. this is equivalent to sending #contents:)."
|
|
674 |
|
|
675 |
self editValue:aStringOrObject selected:false
|
0
|
676 |
!
|
|
677 |
|
125
|
678 |
editValue:aStringOrObject selected:aBoolean
|
|
679 |
"set the contents. If there is a converter, use it to convert
|
|
680 |
the object into a printed representation.
|
|
681 |
Otherwise, the argument is supposed to be a string like object,
|
187
|
682 |
and used directly (i.e. this is equivalent to sending #initialText:selected:)."
|
125
|
683 |
|
|
684 |
|string|
|
|
685 |
|
|
686 |
converter notNil ifTrue:[
|
|
687 |
string := converter printStringFor:aStringOrObject
|
|
688 |
] ifFalse:[
|
|
689 |
string := aStringOrObject.
|
|
690 |
].
|
|
691 |
self contents:string.
|
|
692 |
aBoolean ifTrue:[
|
|
693 |
self selectFromLine:1 col:1 toLine:1 col:string size
|
|
694 |
]
|
|
695 |
!
|
|
696 |
|
187
|
697 |
initialText:aString selected:aBoolean
|
|
698 |
"set the initialText and select it if aBoolean is true"
|
|
699 |
|
|
700 |
|len s|
|
125
|
701 |
|
187
|
702 |
leftOffset := 0.
|
|
703 |
(s := aString) notNil ifTrue:[
|
|
704 |
s := s asString
|
|
705 |
].
|
|
706 |
self contents:s.
|
|
707 |
aBoolean ifTrue:[
|
|
708 |
(len := s size) ~~ 0 ifTrue:[
|
|
709 |
self selectFromLine:1 col:1 toLine:1 col:len
|
|
710 |
]
|
|
711 |
]
|
|
712 |
!
|
|
713 |
|
|
714 |
initialText:aString
|
|
715 |
"set the initialText and select it"
|
|
716 |
|
|
717 |
self initialText:aString selected:true
|
|
718 |
!
|
|
719 |
|
|
720 |
stringValue
|
|
721 |
"alias for #contents - for compatibility with ST-80's InputField"
|
|
722 |
|
|
723 |
^ self contents
|
125
|
724 |
!
|
|
725 |
|
|
726 |
converter:aConverter
|
|
727 |
"set the converter. If non-nil,
|
|
728 |
the converter is applied to the text to convert from the string
|
|
729 |
representation to the actual object value and vice versa.
|
|
730 |
The default converter is nil, meaning no-conversion
|
|
731 |
(i.e. the edited object is the string itself."
|
|
732 |
|
|
733 |
converter := aConverter
|
|
734 |
!
|
|
735 |
|
|
736 |
converter
|
|
737 |
"return the converter (if any)."
|
|
738 |
|
|
739 |
^ converter
|
187
|
740 |
! !
|
|
741 |
|
|
742 |
!EditField methodsFor:'accessing-look'!
|
125
|
743 |
|
155
|
744 |
passwordCharacter:aCharacter
|
|
745 |
passwordCharacter := aCharacter
|
|
746 |
|
|
747 |
"Modified: 6.9.1995 / 12:25:33 / claus"
|
|
748 |
!
|
|
749 |
|
|
750 |
passwordCharacter
|
|
751 |
^ passwordCharacter
|
|
752 |
|
|
753 |
"Modified: 6.9.1995 / 12:25:39 / claus"
|
|
754 |
!
|
|
755 |
|
|
756 |
maxChars
|
|
757 |
"return the maximum number of characters that are allowed in
|
|
758 |
the field.
|
|
759 |
A limit of nil means: unlimited. This is the default."
|
|
760 |
|
|
761 |
^ lengthLimit
|
|
762 |
|
|
763 |
"Modified: 6.9.1995 / 13:43:33 / claus"
|
|
764 |
!
|
|
765 |
|
125
|
766 |
maxChars:aNumberOrNil
|
|
767 |
"set the maximum number of characters that are allowed in
|
|
768 |
the field. Additional input will be ignored by the field.
|
|
769 |
A limit of nil means: unlimited. This is the default.
|
|
770 |
This method has been renamed from #lengthLimit: for ST-80
|
|
771 |
compatibility."
|
|
772 |
|
|
773 |
lengthLimit := aNumberOrNil
|
187
|
774 |
! !
|
|
775 |
|
|
776 |
!EditField methodsFor:'accessing-behavior'!
|
|
777 |
|
|
778 |
entryCompletionBlock:aOneArgBlock
|
|
779 |
"define an action to be evaluated when Tab (NameCompletion) is pressed.
|
|
780 |
The block gets the current contents as argument."
|
|
781 |
|
|
782 |
entryCompletionBlock := aOneArgBlock
|
|
783 |
!
|
|
784 |
|
|
785 |
leaveAction:aBlock
|
|
786 |
"define an action to be evaluated when field is left by return key"
|
|
787 |
|
|
788 |
leaveAction := aBlock
|
|
789 |
!
|
|
790 |
|
|
791 |
enable
|
|
792 |
"enable the field; show cursor and allow input"
|
|
793 |
|
|
794 |
enabled ifFalse:[
|
|
795 |
"/ enableAction notNil ifTrue:[
|
|
796 |
"/ enableAction value
|
|
797 |
"/ ].
|
|
798 |
enabled := true.
|
|
799 |
super showCursor
|
|
800 |
]
|
|
801 |
!
|
|
802 |
|
|
803 |
immediateAccept:aBoolean
|
|
804 |
"set/clear the immediateAccept flag. The default is false."
|
|
805 |
|
|
806 |
immediateAccept := aBoolean
|
|
807 |
!
|
|
808 |
|
|
809 |
leaveKeys:aCollectionOfKeySymbols
|
|
810 |
"define the set of keys which are interpreted as leaveKeys.
|
|
811 |
I.e. those that make the field inactive and accept (if acceptOnLeave is true).
|
|
812 |
The default is a set of #CursorUp, #CursorDown, #Next, #Prior and #Return."
|
|
813 |
|
|
814 |
leaveKeys := aCollectionOfKeySymbols
|
125
|
815 |
!
|
|
816 |
|
187
|
817 |
crAction:aBlock
|
|
818 |
"define an action to be evaluated when the return key is pressed."
|
|
819 |
|
|
820 |
crAction := aBlock
|
|
821 |
!
|
|
822 |
|
|
823 |
tabAction:aBlock
|
|
824 |
"define an action to be evaluated when the tabulator key is pressed."
|
|
825 |
|
|
826 |
tabAction := aBlock
|
|
827 |
!
|
|
828 |
|
|
829 |
acceptOnReturn:aBoolean
|
|
830 |
"set/clear the acceptOnReturn flag. The default is false."
|
|
831 |
|
|
832 |
acceptOnReturn := aBoolean
|
|
833 |
!
|
|
834 |
|
|
835 |
disable
|
|
836 |
"disable the field; hide cursor and ignore input"
|
125
|
837 |
|
187
|
838 |
enabled ifTrue:[
|
|
839 |
enabled := false.
|
|
840 |
self hideCursor
|
|
841 |
]
|
|
842 |
!
|
|
843 |
|
|
844 |
acceptOnLeave:aBoolean
|
|
845 |
"set/clear the acceptOnLeave flag. The default is false."
|
|
846 |
|
|
847 |
acceptOnLeave := aBoolean
|
|
848 |
!
|
|
849 |
|
|
850 |
enableAction:aBlock
|
|
851 |
"define an action to be evaluated when enabled by clicking upon"
|
|
852 |
|
|
853 |
enableAction := aBlock
|
|
854 |
!
|
|
855 |
|
|
856 |
cursorMovementWhenUpdating:aSymbol
|
|
857 |
"define what should be done with the cursor, when I update
|
|
858 |
my contents from the model. Allowed argumetns are:
|
|
859 |
#keep / nil -> stay where it was
|
|
860 |
#endOfLine -> position cursor after the string
|
|
861 |
#beginOfLine -> position cursor to the beginning
|
|
862 |
The default is #endOfLine"
|
|
863 |
|
|
864 |
cursorMovementWhenUpdating := aSymbol
|
125
|
865 |
! !
|
|
866 |
|
|
867 |
!EditField methodsFor:'initialization'!
|
|
868 |
|
0
|
869 |
initStyle
|
|
870 |
super initStyle.
|
|
871 |
|
59
|
872 |
DefaultBackgroundColor notNil ifTrue:[
|
|
873 |
bgColor := DefaultBackgroundColor on:device.
|
|
874 |
self viewBackground:bgColor.
|
0
|
875 |
].
|
59
|
876 |
fgColor := DefaultForegroundColor.
|
|
877 |
selectionFgColor := DefaultSelectionForegroundColor.
|
|
878 |
selectionBgColor := DefaultSelectionBackgroundColor.
|
0
|
879 |
|
59
|
880 |
DefaultFont notNil ifTrue:[
|
|
881 |
font := DefaultFont on:device
|
0
|
882 |
]
|
|
883 |
!
|
|
884 |
|
125
|
885 |
initialize
|
|
886 |
super initialize.
|
|
887 |
self height:(font height + font descent + (topMargin * 2)).
|
|
888 |
enabled := true.
|
|
889 |
fixedSize := true.
|
|
890 |
nFullLinesShown := 1.
|
|
891 |
nLinesShown := 1.
|
130
|
892 |
immediateAccept := false.
|
|
893 |
"/ acceptOnLeave := false.
|
|
894 |
"/ acceptOnReturn := false.
|
|
895 |
acceptOnLeave := acceptOnReturn := true.
|
125
|
896 |
cursorShown := true.
|
|
897 |
leaveKeys := self class defaultLeaveKeys.
|
187
|
898 |
cursorMovementWhenUpdating := #endOfLine
|
125
|
899 |
!
|
|
900 |
|
97
|
901 |
editMenu
|
|
902 |
|labels selectors m|
|
0
|
903 |
|
97
|
904 |
labels := #(
|
|
905 |
'copy'
|
|
906 |
'cut'
|
|
907 |
'paste'
|
19
|
908 |
"
|
97
|
909 |
'replace'
|
19
|
910 |
"
|
97
|
911 |
'-'
|
|
912 |
'accept'
|
|
913 |
).
|
0
|
914 |
|
97
|
915 |
selectors := #(
|
|
916 |
copySelection
|
|
917 |
cut
|
|
918 |
paste
|
|
919 |
"
|
|
920 |
replace
|
19
|
921 |
"
|
97
|
922 |
nil
|
|
923 |
accept
|
|
924 |
).
|
|
925 |
|
|
926 |
m := PopUpMenu
|
|
927 |
labels:(resources array:labels)
|
|
928 |
selectors:selectors.
|
|
929 |
|
|
930 |
self hasSelection ifFalse:[
|
131
|
931 |
m disableAll:#(copySelection cut)
|
97
|
932 |
].
|
|
933 |
|
|
934 |
^ m
|
0
|
935 |
! !
|
|
936 |
|
|
937 |
!EditField methodsFor:'realization'!
|
|
938 |
|
|
939 |
realize
|
|
940 |
"scroll back to beginning when realized"
|
|
941 |
leftOffset := 0.
|
|
942 |
super realize
|
|
943 |
! !
|
|
944 |
|
38
|
945 |
!EditField methodsFor:'queries'!
|
|
946 |
|
155
|
947 |
specClass
|
|
948 |
self class == EditField ifTrue:[^ InputFieldSpec].
|
|
949 |
^ nil
|
|
950 |
|
|
951 |
"Modified: 5.9.1995 / 17:28:27 / claus"
|
|
952 |
!
|
|
953 |
|
130
|
954 |
preferredExtent
|
|
955 |
"return the preferred extent of this view.
|
38
|
956 |
That is the width of the string plus some extra,
|
|
957 |
but not wider than half of the screen"
|
|
958 |
|
155
|
959 |
|string w f|
|
38
|
960 |
|
|
961 |
string := self contents.
|
|
962 |
(string isNil or:[string isBlank]) ifTrue:[
|
130
|
963 |
string := ' ' "/ just any string is ok ^ super preferredExtent
|
38
|
964 |
].
|
155
|
965 |
f := font on:device.
|
|
966 |
w := ((f widthOf:string) * 1.5) rounded.
|
38
|
967 |
w := w min:(device width // 2).
|
155
|
968 |
^ w @ (f height * 1.5) rounded
|
|
969 |
|
|
970 |
"Modified: 6.9.1995 / 19:24:06 / claus"
|
38
|
971 |
! !
|
|
972 |
|
0
|
973 |
!EditField methodsFor:'cursor drawing'!
|
|
974 |
|
155
|
975 |
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
|
|
976 |
startVisLineNr to:endVisLineNr do:[:visLine |
|
|
977 |
self drawVisibleLine:visLine with:fg and:bg
|
|
978 |
]
|
|
979 |
|
|
980 |
"Modified: 6.9.1995 / 12:24:29 / claus"
|
|
981 |
!
|
|
982 |
|
0
|
983 |
showCursor
|
|
984 |
"make cursor visible if currently invisible - but only if this
|
|
985 |
EditField is enabled"
|
|
986 |
|
|
987 |
enabled ifTrue:[super showCursor]
|
|
988 |
! !
|
|
989 |
|
|
990 |
!EditField methodsFor:'cursor movement'!
|
|
991 |
|
125
|
992 |
cursorCol:col
|
|
993 |
"redefined to lock the cursor at the end, if I have a lngthLimit"
|
|
994 |
|
|
995 |
|c sz|
|
|
996 |
|
|
997 |
c := col.
|
|
998 |
lengthLimit notNil ifTrue:[
|
|
999 |
sz := lengthLimit.
|
|
1000 |
c > sz ifTrue:[
|
|
1001 |
c := sz+1.
|
|
1002 |
]
|
|
1003 |
].
|
|
1004 |
super cursorCol:c
|
|
1005 |
!
|
|
1006 |
|
0
|
1007 |
cursorLine:line col:col
|
38
|
1008 |
"catch cursor movement"
|
|
1009 |
|
|
1010 |
super cursorLine:1 col:col
|
0
|
1011 |
!
|
|
1012 |
|
|
1013 |
cursorDown
|
|
1014 |
"catch cursor movement"
|
|
1015 |
|
|
1016 |
(cursorVisibleLine == nLinesShown) ifFalse:[
|
59
|
1017 |
super cursorDown
|
0
|
1018 |
]
|
|
1019 |
! !
|
|
1020 |
|
70
|
1021 |
!EditField methodsFor:'event handling'!
|
19
|
1022 |
|
125
|
1023 |
keyPress:key x:x y:y
|
|
1024 |
"if keyHandler is defined, pass input; otherwise check for leave
|
|
1025 |
keys"
|
|
1026 |
|
132
|
1027 |
<resource: #keyboard (#DeleteLine #EndOfText)>
|
|
1028 |
|
163
|
1029 |
|leave xCol newOffset oldWidth newWidth s|
|
125
|
1030 |
|
|
1031 |
enabled ifFalse:[
|
127
|
1032 |
^ self
|
125
|
1033 |
].
|
|
1034 |
|
|
1035 |
(key == #DeleteLine) ifTrue:[
|
127
|
1036 |
Smalltalk at:#CopyBuffer put:(self contents).
|
|
1037 |
self contents:''. ^ self
|
125
|
1038 |
].
|
19
|
1039 |
|
125
|
1040 |
(key == #Tab) ifTrue:[
|
127
|
1041 |
tabAction notNil ifTrue:[tabAction value. ^ self].
|
144
|
1042 |
entryCompletionBlock notNil ifTrue:[
|
163
|
1043 |
s := self contents.
|
|
1044 |
s isNil ifTrue:[
|
|
1045 |
s := ''
|
|
1046 |
] ifFalse:[
|
|
1047 |
s := s asString
|
|
1048 |
].
|
|
1049 |
entryCompletionBlock value:s. ^ self
|
144
|
1050 |
]
|
125
|
1051 |
].
|
|
1052 |
(key == #Return) ifTrue:[
|
127
|
1053 |
crAction notNil ifTrue:[crAction value. ^ self].
|
125
|
1054 |
].
|
|
1055 |
leave := leaveKeys includes:key.
|
|
1056 |
leave ifTrue:[
|
127
|
1057 |
leaveAction notNil ifTrue:[
|
|
1058 |
leaveAction value:key
|
|
1059 |
].
|
121
|
1060 |
|
127
|
1061 |
((key == #Return and:[acceptOnReturn])
|
|
1062 |
or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
|
|
1063 |
self accept.
|
|
1064 |
].
|
125
|
1065 |
|
127
|
1066 |
x >= 0 ifTrue:[
|
|
1067 |
"
|
|
1068 |
let superview know about the leave ...
|
|
1069 |
This is a temporary kludge for the tableWidget -
|
|
1070 |
it is no clean coding style. Should make the tableWidget
|
|
1071 |
a proper model and handle it via the changed mechanism ....
|
|
1072 |
"
|
|
1073 |
(superView notNil and:[superView canHandle:key from:self]) ifTrue:[
|
|
1074 |
superView keyPress:key x:x y:y.
|
|
1075 |
].
|
|
1076 |
].
|
|
1077 |
^ self
|
19
|
1078 |
].
|
121
|
1079 |
|
125
|
1080 |
"
|
|
1081 |
ignore some keys (if not a leaveKey) ...
|
|
1082 |
"
|
|
1083 |
(key == #Find) ifTrue:[^self].
|
|
1084 |
(key == #FindNext) ifTrue:[^self].
|
|
1085 |
(key == #FindPrev) ifTrue:[^self].
|
|
1086 |
(key == #GotoLine) ifTrue:[^self].
|
|
1087 |
|
|
1088 |
"
|
|
1089 |
a normal key - let superclass's method insert it
|
|
1090 |
"
|
|
1091 |
oldWidth := self widthOfContents.
|
|
1092 |
super keyPress:key x:x y:y.
|
|
1093 |
|
|
1094 |
"
|
|
1095 |
for end-of-text, also move to end-of-line
|
|
1096 |
"
|
|
1097 |
key == #EndOfText ifTrue:[
|
127
|
1098 |
super keyPress:#EndOfLine x:x y:y.
|
125
|
1099 |
].
|
|
1100 |
newWidth := self widthOfContents.
|
|
1101 |
|
|
1102 |
"
|
|
1103 |
should (& can) we resize ?
|
|
1104 |
"
|
|
1105 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
|
|
1106 |
(xCol > (width * (5/6))) ifTrue:[
|
130
|
1107 |
self changed:#preferredExtent
|
125
|
1108 |
] ifFalse:[
|
127
|
1109 |
newWidth < (width * (1/6)) ifTrue:[
|
130
|
1110 |
self changed:#preferredExtent
|
127
|
1111 |
]
|
125
|
1112 |
].
|
|
1113 |
|
|
1114 |
"
|
155
|
1115 |
did someone react (i.e. has my extent changed) ?
|
125
|
1116 |
(if not, we scroll horizontally)
|
|
1117 |
"
|
|
1118 |
xCol := (self xOfCol:cursorCol inVisibleLine:cursorLine) - leftOffset.
|
|
1119 |
(xCol > (width * (5/6))) ifTrue:[
|
127
|
1120 |
newOffset := leftOffset + (width // 2).
|
125
|
1121 |
] ifFalse:[
|
127
|
1122 |
(xCol < (width * (1/6))) ifTrue:[
|
|
1123 |
newOffset := 0 max: leftOffset - (width // 2).
|
|
1124 |
] ifFalse:[
|
|
1125 |
newOffset := leftOffset
|
|
1126 |
]
|
125
|
1127 |
].
|
|
1128 |
newOffset ~~ leftOffset ifTrue:[
|
155
|
1129 |
self scrollHorizontalTo:newOffset.
|
|
1130 |
"/ leftOffset := newOffset.
|
|
1131 |
"/ self clear.
|
|
1132 |
"/ self redraw
|
125
|
1133 |
]
|
19
|
1134 |
!
|
0
|
1135 |
|
|
1136 |
buttonPress:button x:x y:y
|
|
1137 |
"enable myself on mouse click"
|
|
1138 |
|
|
1139 |
enabled ifFalse:[
|
59
|
1140 |
enabled := true.
|
|
1141 |
super buttonPress:button x:x y:y.
|
|
1142 |
enableAction notNil ifTrue:[
|
|
1143 |
enableAction value
|
|
1144 |
]
|
0
|
1145 |
] ifTrue:[
|
59
|
1146 |
super buttonPress:button x:x y:y
|
0
|
1147 |
]
|
|
1148 |
!
|
|
1149 |
|
125
|
1150 |
focusIn
|
|
1151 |
"got the explicit focus"
|
0
|
1152 |
|
|
1153 |
enabled ifFalse:[
|
125
|
1154 |
enabled := true.
|
|
1155 |
super focusIn.
|
|
1156 |
enableAction notNil ifTrue:[
|
|
1157 |
enableAction value
|
|
1158 |
]
|
|
1159 |
] ifTrue:[
|
|
1160 |
super focusIn
|
0
|
1161 |
].
|
105
|
1162 |
!
|
|
1163 |
|
|
1164 |
canHandle:aKey
|
|
1165 |
"return true, if the receiver would like to handle aKey
|
|
1166 |
(usually from another view, when the receiver is part of
|
|
1167 |
a more complex dialog box).
|
|
1168 |
We do return true here, since the editfield will handle
|
125
|
1169 |
all keys.
|
|
1170 |
OBSOLETE: dont use this anymore - its a leftover for the tableWidget"
|
105
|
1171 |
|
|
1172 |
^ true
|
0
|
1173 |
! !
|
125
|
1174 |
|
|
1175 |
!EditField methodsFor:'editing'!
|
|
1176 |
|
|
1177 |
paste:someText
|
|
1178 |
"redefined to force text to 1 line"
|
|
1179 |
|
|
1180 |
super paste:someText.
|
|
1181 |
list size > 1 ifTrue:[
|
|
1182 |
self deleteFromLine:2 toLine:(list size)
|
|
1183 |
]
|
|
1184 |
! !
|