author | Claus Gittinger <cg@exept.de> |
Tue, 03 Mar 2015 11:37:29 +0100 | |
changeset 5307 | 32c2e84b9c1d |
parent 5062 | 2a9d94347cc5 |
child 5574 | ee569a490272 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
69 | 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 |
" |
|
3457 | 12 |
"{ Package: 'stx:libwidg' }" |
0 | 13 |
|
7 | 14 |
Object subclass:#EnterFieldGroup |
589 | 15 |
instanceVariableNames:'fields currentField leaveAction wrap leaveOnTabLast' |
278 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Support' |
|
0 | 19 |
! |
20 |
||
1355 | 21 |
!EnterFieldGroup class methodsFor:'documentation'! |
38 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
69 | 26 |
All Rights Reserved |
0 | 27 |
|
38 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
130 | 39 |
EnterFieldGroup controls the interaction between EnterFields |
40 |
enabling the next/prev field when a field is left. |
|
121 | 41 |
Instances of this class keep track of which field of the group is the |
42 |
currentField (i.e. the one getting keyboard input) and forwards input |
|
589 | 43 |
to that one. |
44 |
This is done by arranging for all of my fields to delegate their |
|
45 |
input to me, which is then forwarded to the active field). |
|
121 | 46 |
|
38 | 47 |
The block accessable as leaveAction is evaluated when the last |
121 | 48 |
field of the group is left (by cursor-down or cr). |
589 | 49 |
Usually this block triggers accept on the fields (if they did not already) |
50 |
and/or performs some followup processing and possibly closes the topview |
|
51 |
(for example: in a dialog). |
|
122 | 52 |
|
53 |
EnterFieldGroups can be used as a delegate (of the topView) to forward |
|
54 |
input (entered into the topView) to the currently active field. |
|
55 |
||
56 |
Stepping to previous field is via CursorUp/PreviousField, |
|
57 |
to next field via CursorDown/NextField/Tab. |
|
589 | 58 |
By default, tabbing via #Tab is disabled - to enable it, send the field |
59 |
a #makeTabable or #makeAllTabable to the group. |
|
60 |
||
61 |
All of this here is low level stuff, providing a lot of freedom in |
|
62 |
which keys are handled and how they perform. |
|
63 |
Normally, these are not required for most users - the DialogBox sets up |
|
64 |
things correctly for most cases. |
|
65 |
||
122 | 66 |
|
581 | 67 |
[Instance variables:] |
68 |
||
69 |
fields <Collection of EditField> the fields of the group |
|
122 | 70 |
|
581 | 71 |
currentField <EditField> the active field |
122 | 72 |
|
581 | 73 |
leaveAction <nil|Block> action to perform, when the |
74 |
last field is left by a non-wrap |
|
122 | 75 |
|
581 | 76 |
wrap <Boolean> if true, non-return next-keys wrap |
77 |
back to the first field. |
|
78 |
If false (the default), next in |
|
79 |
the last field is taken as return. |
|
80 |
This is ignored, if no leaveAction was |
|
81 |
defined. |
|
122 | 82 |
|
589 | 83 |
leaveOnTabLast <Boolean> if true, tabbing out of the last |
84 |
field leaves the group. |
|
85 |
The default is false. |
|
86 |
||
581 | 87 |
[author:] |
88 |
Claus Gittinger |
|
589 | 89 |
|
90 |
||
91 |
[see also:] |
|
92 |
DialogBox |
|
93 |
EditField |
|
121 | 94 |
" |
95 |
! |
|
96 |
||
97 |
examples |
|
98 |
" |
|
122 | 99 |
without a group - user has to enter mouse into the next field to activate it; |
100 |
Cursor-keys dont work: |
|
589 | 101 |
[exBegin] |
102 |
|top panel field1 field2 field3| |
|
121 | 103 |
|
589 | 104 |
top := StandardSystemView new. |
105 |
top extent:200@200. |
|
121 | 106 |
|
589 | 107 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
121 | 108 |
|
589 | 109 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
110 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
111 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
121 | 112 |
|
589 | 113 |
top open |
114 |
[exEnd] |
|
121 | 115 |
|
116 |
||
117 |
with a group - Return-key or CursorKey enables next field: |
|
122 | 118 |
(but still, mouse pointer has to be moved into any of the fields, |
589 | 119 |
because the topView does not forward its input into the fields. |
120 |
Also, tabbing is not possible here) |
|
121 |
[exBegin] |
|
122 |
|top panel group field1 field2 field3| |
|
121 | 123 |
|
589 | 124 |
top := StandardSystemView new. |
125 |
top extent:200@200. |
|
121 | 126 |
|
589 | 127 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
121 | 128 |
|
589 | 129 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
130 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
131 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
121 | 132 |
|
589 | 133 |
group := EnterFieldGroup new. |
134 |
group add:field1; add:field2; add:field3. |
|
121 | 135 |
|
589 | 136 |
top open |
137 |
[exEnd] |
|
121 | 138 |
|
139 |
||
140 |
||
589 | 141 |
same, enables tabbing within the group via the Tab key |
142 |
(but still, the mouse pointer must be in one of the fields): |
|
143 |
[exBegin] |
|
144 |
|top panel group field1 field2 field3| |
|
122 | 145 |
|
589 | 146 |
top := StandardSystemView new. |
147 |
top extent:200@200. |
|
122 | 148 |
|
589 | 149 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
122 | 150 |
|
589 | 151 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
152 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
153 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
154 |
||
155 |
group := EnterFieldGroup new. |
|
156 |
group add:field1; add:field2; add:field3. |
|
122 | 157 |
|
589 | 158 |
field1 makeTabable. |
159 |
field2 makeTabable. |
|
160 |
field3 makeTabable. |
|
161 |
top open |
|
162 |
[exEnd] |
|
163 |
individual makeTabable messages to the fields allows single |
|
164 |
fields to be sticky (i.e. explicit click is needed to get out |
|
165 |
of it) - this is very seldom required. |
|
166 |
To make all fields tabable (the usual case), there is a shortCut: |
|
167 |
[exBegin] |
|
168 |
|top panel group field1 field2 field3| |
|
122 | 169 |
|
589 | 170 |
top := StandardSystemView new. |
171 |
top extent:200@200. |
|
172 |
||
173 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
122 | 174 |
|
589 | 175 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
176 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
177 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
178 |
||
179 |
group := EnterFieldGroup new. |
|
180 |
group add:field1; add:field2; add:field3. |
|
181 |
group makeAllTabable. |
|
182 |
||
183 |
top open |
|
184 |
[exEnd] |
|
122 | 185 |
|
186 |
||
187 |
||
589 | 188 |
use a delagation from the outerView to the group - |
189 |
Return-key or CursorKey enables next field: |
|
190 |
input for topView is delegated to the group, which also behaves |
|
191 |
as a unit w.r.t. keyboard focus (move pointer in and out). |
|
192 |
Again, without tabbing: |
|
193 |
[exBegin] |
|
194 |
|top panel group field1 field2 field3| |
|
122 | 195 |
|
589 | 196 |
top := StandardSystemView new. |
197 |
top extent:200@200. |
|
198 |
||
199 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
122 | 200 |
|
589 | 201 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
202 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
203 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
204 |
||
205 |
group := EnterFieldGroup new. |
|
206 |
group add:field1; add:field2; add:field3. |
|
122 | 207 |
|
589 | 208 |
top delegate:group. |
209 |
top open |
|
210 |
[exEnd] |
|
211 |
||
212 |
||
213 |
and, with tabbing: |
|
214 |
[exBegin] |
|
215 |
|top panel group field1 field2 field3| |
|
216 |
||
217 |
top := StandardSystemView new. |
|
218 |
top extent:200@200. |
|
122 | 219 |
|
589 | 220 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
221 |
||
222 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
|
223 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
224 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
122 | 225 |
|
589 | 226 |
group := EnterFieldGroup new. |
227 |
group add:field1; add:field2; add:field3. |
|
228 |
group makeAllTabable. |
|
229 |
||
230 |
top delegate:group. |
|
231 |
top open |
|
232 |
[exEnd] |
|
122 | 233 |
|
234 |
||
235 |
||
589 | 236 |
as above, but close the box when the last field is left |
237 |
via return - notice, that tabbing still wraps around: |
|
238 |
[exBegin] |
|
239 |
|top panel group field1 field2 field3| |
|
122 | 240 |
|
589 | 241 |
top := StandardSystemView new. |
242 |
top extent:200@200. |
|
122 | 243 |
|
589 | 244 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
122 | 245 |
|
589 | 246 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
247 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
248 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
122 | 249 |
|
589 | 250 |
group := EnterFieldGroup new. |
251 |
group add:field1; add:field2; add:field3. |
|
252 |
group leaveAction:[top destroy]. |
|
253 |
group makeAllTabable. |
|
122 | 254 |
|
589 | 255 |
top delegate:group. |
256 |
top open |
|
257 |
[exEnd] |
|
122 | 258 |
|
589 | 259 |
in the next example, tabbing out of the last field |
260 |
closes the box as well: |
|
261 |
[exBegin] |
|
262 |
|top panel group field1 field2 field3| |
|
121 | 263 |
|
589 | 264 |
top := StandardSystemView new. |
265 |
top extent:200@200. |
|
121 | 266 |
|
589 | 267 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
121 | 268 |
|
589 | 269 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
270 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
271 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
121 | 272 |
|
589 | 273 |
group := EnterFieldGroup new. |
274 |
group add:field1; add:field2; add:field3. |
|
275 |
group leaveAction:[top destroy]. |
|
276 |
group makeAllTabable. |
|
277 |
group leaveOnTabLast:true. |
|
122 | 278 |
|
589 | 279 |
top delegate:group. |
280 |
top open |
|
281 |
[exEnd] |
|
122 | 282 |
|
283 |
||
284 |
the next example shows that the input order is defined by the |
|
285 |
order in the group; NOT by the physical layout of the fields in the superview: |
|
130 | 286 |
(i.e. you can arrange your fields in multiple framedBoxes, panels or |
287 |
subviews - independent of the tab-stepping order) |
|
589 | 288 |
[exBegin] |
289 |
|top panel group field1 field2 field3| |
|
122 | 290 |
|
589 | 291 |
top := StandardSystemView label:'reverse'. |
292 |
top extent:200@200. |
|
122 | 293 |
|
589 | 294 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
122 | 295 |
|
589 | 296 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
297 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
298 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
122 | 299 |
|
589 | 300 |
group := EnterFieldGroup new. |
301 |
group add:field3; add:field2; add:field1. |
|
302 |
group leaveAction:[top destroy]. |
|
303 |
group makeAllTabable. |
|
122 | 304 |
|
589 | 305 |
top delegate:group. |
306 |
top open |
|
307 |
[exEnd] |
|
122 | 308 |
|
309 |
||
310 |
||
311 |
using a single model for all fields: |
|
312 |
(here, we use a Plug to simulate a more complex model): |
|
589 | 313 |
[exBegin] |
314 |
|top panel group field1 field2 field3 model |
|
315 |
value1 value2 value3| |
|
122 | 316 |
|
589 | 317 |
top := StandardSystemView new. |
318 |
top extent:200@200. |
|
122 | 319 |
|
589 | 320 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
122 | 321 |
|
589 | 322 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
323 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
324 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
122 | 325 |
|
589 | 326 |
group := EnterFieldGroup new. |
327 |
group add:field1; add:field2; add:field3. |
|
328 |
group leaveAction:[top destroy]. |
|
329 |
group makeAllTabable. |
|
122 | 330 |
|
589 | 331 |
value1 := 'one'. value2 := 'two'. value3 := 'three'. |
122 | 332 |
|
589 | 333 |
model := Plug new. |
334 |
model respondTo:#value1 with:[value1]. |
|
335 |
model respondTo:#value1: with:[:arg | value1 := arg]. |
|
336 |
model respondTo:#value2 with:[value2]. |
|
337 |
model respondTo:#value2: with:[:arg | value2 := arg]. |
|
338 |
model respondTo:#value3 with:[value3]. |
|
339 |
model respondTo:#value3: with:[:arg | value3 := arg]. |
|
122 | 340 |
|
589 | 341 |
field1 model:model; aspect:#value1; change:#value1:. |
342 |
field2 model:model; aspect:#value2; change:#value2:. |
|
343 |
field3 model:model; aspect:#value3; change:#value3:. |
|
122 | 344 |
|
589 | 345 |
top delegate:group. |
346 |
top openModal. |
|
122 | 347 |
|
655 | 348 |
Transcript showCR:'value1: ' , value1. |
349 |
Transcript showCR:'value2: ' , value2. |
|
350 |
Transcript showCR:'value3: ' , value3. |
|
589 | 351 |
[exEnd] |
122 | 352 |
|
353 |
||
589 | 354 |
all of the above is done automatically for you, |
355 |
if you add inputFields to a dialogBox. |
|
356 |
Here, all fields use the same model, but different aspects: |
|
357 |
[exBegin] |
|
358 |
|box model |
|
359 |
value1 value2 value3| |
|
360 |
||
361 |
box := DialogBox new. |
|
362 |
box extent:200@200. |
|
363 |
||
364 |
value1 := 'one'. value2 := 'two'. value3 := 'three'. |
|
122 | 365 |
|
589 | 366 |
model := Plug new. |
367 |
model respondTo:#value1 with:[value1]. |
|
368 |
model respondTo:#value1: with:[:arg | value1 := arg]. |
|
369 |
model respondTo:#value2 with:[value2]. |
|
370 |
model respondTo:#value2: with:[:arg | value2 := arg]. |
|
371 |
model respondTo:#value3 with:[value3]. |
|
372 |
model respondTo:#value3: with:[:arg | value3 := arg]. |
|
122 | 373 |
|
589 | 374 |
(box addInputFieldOn:model) aspect:#value1; change:#value1:. |
375 |
box addVerticalSpace. |
|
376 |
(box addInputFieldOn:model) aspect:#value2; change:#value2:. |
|
377 |
box addVerticalSpace. |
|
378 |
(box addInputFieldOn:model) aspect:#value3; change:#value3:. |
|
122 | 379 |
|
589 | 380 |
box addOkButton. |
381 |
||
382 |
box open. |
|
122 | 383 |
|
655 | 384 |
Transcript showCR:'value1: ' , value1. |
385 |
Transcript showCR:'value2: ' , value2. |
|
386 |
Transcript showCR:'value3: ' , value3. |
|
589 | 387 |
[exEnd] |
388 |
||
389 |
Here, the fields use different models, but the same aspect: |
|
390 |
[exBegin] |
|
391 |
|box model |
|
392 |
valueHolder1 valueHolder2 valueHolder3| |
|
393 |
||
394 |
box := DialogBox new. |
|
395 |
box extent:200@200. |
|
396 |
||
397 |
valueHolder1 := 'one' asValue. |
|
398 |
valueHolder2 := 'two' asValue. |
|
399 |
valueHolder3 := 'three' asValue. |
|
122 | 400 |
|
589 | 401 |
box addInputFieldOn:valueHolder1. |
402 |
box addVerticalSpace. |
|
403 |
box addInputFieldOn:valueHolder2. |
|
404 |
box addVerticalSpace. |
|
405 |
box addInputFieldOn:valueHolder3. |
|
406 |
||
407 |
box addOkButton. |
|
122 | 408 |
|
589 | 409 |
box open. |
122 | 410 |
|
655 | 411 |
Transcript showCR:'value1: ' , valueHolder1 value. |
412 |
Transcript showCR:'value2: ' , valueHolder2 value. |
|
413 |
Transcript showCR:'value3: ' , valueHolder3 value. |
|
589 | 414 |
[exEnd] |
38 | 415 |
" |
589 | 416 |
|
417 |
"Created: 27.4.1996 / 16:43:28 / cg" |
|
38 | 418 |
! ! |
0 | 419 |
|
278 | 420 |
!EnterFieldGroup methodsFor:'accessing'! |
122 | 421 |
|
5059 | 422 |
currentField |
423 |
"return the field which currently has the focus" |
|
424 |
||
425 |
^ currentField |
|
426 |
! |
|
427 |
||
278 | 428 |
fields |
429 |
"return a collection of the inputFields contained in the group." |
|
122 | 430 |
|
278 | 431 |
^ fields |
432 |
! |
|
199 | 433 |
|
434 |
leaveAction:aBlock |
|
435 |
"set the action to perform when the last field is left. |
|
436 |
Usually, this is to accept the values of all fields and perform |
|
437 |
some additional processing (such as closing a dialog)." |
|
438 |
||
439 |
leaveAction := aBlock |
|
440 |
! |
|
441 |
||
589 | 442 |
leaveOnTabLast:aBoolean |
443 |
"specifies if leaving the last field via Tab |
|
444 |
should leave the group or stay in the group. |
|
445 |
(if staying, either wrap or not, depending on the setting of wrap) |
|
446 |
The default is to stay in the group" |
|
447 |
||
448 |
leaveOnTabLast := aBoolean |
|
449 |
||
450 |
"Created: 27.4.1996 / 17:22:30 / cg" |
|
451 |
"Modified: 27.4.1996 / 17:22:44 / cg" |
|
452 |
! |
|
453 |
||
454 |
makeAllTabable |
|
455 |
"make all fields tabable" |
|
456 |
||
457 |
fields do:[:field | |
|
458 |
field makeTabable |
|
459 |
] |
|
460 |
||
461 |
"Created: 27.4.1996 / 17:11:41 / cg" |
|
462 |
! |
|
463 |
||
199 | 464 |
wrap:aBoolean |
278 | 465 |
"specifies if leaving the last field via non-Return |
589 | 466 |
(i.e. Tab or Cursor-Down) should wrap back to the first, |
467 |
or leave the group. |
|
468 |
The default is to not leave the group and wrap back to the first field." |
|
199 | 469 |
|
470 |
wrap := aBoolean |
|
589 | 471 |
|
472 |
"Modified: 27.4.1996 / 17:19:50 / cg" |
|
199 | 473 |
! ! |
474 |
||
2144 | 475 |
!EnterFieldGroup methodsFor:'adding & removing'! |
0 | 476 |
|
477 |
add:aField |
|
1355 | 478 |
"add another field to the group. |
479 |
Cursor motion out of the previous field will lead to the next |
|
480 |
one and vice versa." |
|
481 |
||
482 |
self add:aField before:nil |
|
483 |
||
484 |
"Modified: 18.10.1997 / 03:19:51 / cg" |
|
485 |
! |
|
486 |
||
487 |
add:aField before:anotherField |
|
488 |
"add another field to the group into a particular position |
|
489 |
within the tabbing order. |
|
490 |
Cursor motion out of the previous field will lead to the next |
|
491 |
one and vice versa." |
|
0 | 492 |
|
493 |
fields isNil ifTrue:[ |
|
589 | 494 |
fields := OrderedCollection new |
0 | 495 |
]. |
1355 | 496 |
|
497 |
anotherField isNil ifTrue:[ |
|
498 |
fields add:aField. |
|
499 |
] ifFalse:[ |
|
500 |
fields add:aField before:anotherField |
|
501 |
]. |
|
121 | 502 |
|
7 | 503 |
aField delegate:self. |
121 | 504 |
aField hideCursor. |
596 | 505 |
"/ aField disable. |
0 | 506 |
|
507 |
"set the fields enableAction to disable active field" |
|
508 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
509 |
aField clickAction:[:field | |
589 | 510 |
self makeActive:field |
0 | 511 |
]. |
512 |
||
513 |
"set the fields leaveAction to enable next field" |
|
514 |
||
1795 | 515 |
aField leaveAction:[:field :key | |
516 |
self fieldLeft:field withKey:key |
|
121 | 517 |
]. |
518 |
||
519 |
fields size == 1 ifTrue:[ |
|
589 | 520 |
"the first one" |
521 |
self makeActive:aField |
|
0 | 522 |
] |
589 | 523 |
|
1355 | 524 |
"Created: 18.10.1997 / 03:06:00 / cg" |
525 |
"Modified: 18.10.1997 / 03:20:36 / cg" |
|
526 |
! |
|
527 |
||
528 |
remove:aField |
|
529 |
"remove a field from the group." |
|
530 |
||
531 |
fields isNil ifTrue:[^ self]. |
|
532 |
(fields includesIdentical:aField) ifFalse:[^ self]. |
|
533 |
||
534 |
fields removeIdentical:aField. |
|
535 |
||
536 |
"Created: 18.10.1997 / 02:53:29 / cg" |
|
537 |
"Modified: 18.10.1997 / 03:21:09 / cg" |
|
0 | 538 |
! ! |
539 |
||
199 | 540 |
!EnterFieldGroup methodsFor:'event forwarding'! |
541 |
||
542 |
buttonPress:button x:x y:y view:aView |
|
543 |
"clicking on a field activates it and forwards the click to it" |
|
544 |
||
545 |
self makeActive:aView. |
|
546 |
aView buttonPress:button x:x y:y |
|
547 |
! |
|
548 |
||
549 |
handlesButtonPress:button inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
550 |
"query from event processor: am I interested in button-events ? |
199 | 551 |
yes I am (to activate the clicked-on field)." |
122 | 552 |
|
199 | 553 |
^ true |
554 |
! |
|
555 |
||
556 |
handlesKeyPress:key inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
557 |
"query from event processor: am I interested in key-events ? |
199 | 558 |
yes I am (to forward it to the active field)." |
559 |
||
560 |
^ true |
|
561 |
! |
|
562 |
||
563 |
handlesKeyRelease:key inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
564 |
"query from event processor: am I interested in key-events ? |
199 | 565 |
yes I am (to forward it to the active field)." |
566 |
||
567 |
^ true |
|
568 |
! |
|
121 | 569 |
|
199 | 570 |
keyPress:key x:x y:y view:aView |
571 |
"key-press in any field - forward the key to the active field |
|
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
572 |
(with nil coordinates to indicate that the key was pressed |
199 | 573 |
outside. However, this info is not used by any view currently)" |
574 |
||
575 |
currentField notNil ifTrue:[ |
|
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
576 |
currentField keyPress:key x:nil y:nil |
199 | 577 |
] |
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
578 |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
579 |
"Modified: / 18.9.1998 / 20:00:36 / cg" |
199 | 580 |
! |
581 |
||
582 |
keyRelease:key x:x y:y view:aView |
|
583 |
"key-release in any field - forward the key to the active field. |
|
584 |
(with -1/-1 as coordinate to indicate that the key was pressed |
|
585 |
outside. However, this info is not used by any view currently)" |
|
586 |
||
587 |
currentField notNil ifTrue:[ |
|
588 |
currentField keyRelease:key x:-1 y:-1 |
|
589 |
] |
|
589 | 590 |
! |
591 |
||
592 |
showFocus:onOrOff |
|
593 |
"forward focus display to the active field " |
|
594 |
||
595 |
currentField notNil ifTrue:[ |
|
596 |
currentField showFocus:onOrOff |
|
597 |
] |
|
598 |
||
599 |
"Modified: 4.3.1996 / 22:18:22 / cg" |
|
600 |
"Created: 27.4.1996 / 16:41:38 / cg" |
|
601 |
! |
|
602 |
||
603 |
showNoFocus:onOrOff |
|
604 |
"forward nofocus display to the active field " |
|
605 |
||
606 |
currentField notNil ifTrue:[ |
|
607 |
currentField showNoFocus:onOrOff |
|
608 |
] |
|
609 |
||
610 |
"Modified: 4.3.1996 / 22:18:22 / cg" |
|
611 |
"Created: 27.4.1996 / 16:42:07 / cg" |
|
0 | 612 |
! ! |
613 |
||
661 | 614 |
!EnterFieldGroup methodsFor:'group control'! |
615 |
||
1355 | 616 |
fieldLeft:aField withKey:key |
1373 | 617 |
"some of my fields was left using key. |
618 |
Figure out, which one to give the focus: |
|
619 |
If there are more fields, go to that one; |
|
620 |
otherwise, handle this like tabbing to the next component" |
|
621 |
||
3457 | 622 |
|thisIndex action next wg explicit nFields nextField delta| |
661 | 623 |
|
624 |
action := key. |
|
625 |
nFields := fields size. |
|
1355 | 626 |
thisIndex := fields indexOf:aField. |
661 | 627 |
|
628 |
((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[ |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
629 |
delta := -1. |
661 | 630 |
(thisIndex == 1) ifTrue:[ |
631 |
next := nFields |
|
632 |
] ifFalse:[ |
|
633 |
next := thisIndex - 1 |
|
634 |
] |
|
635 |
]. |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
636 |
|
661 | 637 |
((key == #CursorDown) |
638 |
or:[key == #NextField |
|
639 |
or:[key == #Tab]]) ifTrue:[ |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
640 |
delta := 1. |
661 | 641 |
(thisIndex == nFields) ifTrue:[ |
642 |
next := 1. |
|
643 |
wrap == false ifTrue:[ |
|
644 |
action := #Return. |
|
645 |
]. |
|
646 |
] ifFalse:[ |
|
647 |
next := thisIndex + 1 |
|
648 |
] |
|
649 |
]. |
|
650 |
((action == #Return) |
|
651 |
or:[key == #Tab and:[leaveOnTabLast == true]]) ifTrue:[ |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
652 |
delta := 1. |
661 | 653 |
(thisIndex == nFields) ifTrue:[ |
654 |
leaveAction notNil ifTrue:[ |
|
655 |
self makeInactive:aField. |
|
656 |
currentField := nil. |
|
657 |
leaveAction value. |
|
658 |
next := nil |
|
659 |
] ifFalse:[ |
|
660 |
next := 1 |
|
661 |
] |
|
662 |
] ifFalse:[ |
|
663 |
next := thisIndex + 1 |
|
664 |
] |
|
665 |
]. |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
666 |
|
661 | 667 |
next notNil ifTrue:[ |
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
668 |
"/ search for the next enabled field |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
669 |
|
661 | 670 |
nextField := fields at:next. |
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
671 |
[nextField notNil |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
672 |
and:[nextField enabled not |
2028
4f5c00067ee7
when checking for realized fields, ask via #reallyRealized;
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
673 |
or:[nextField reallyRealized not]]] whileTrue:[ |
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
674 |
next := next + delta. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
675 |
next < 1 ifTrue:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
676 |
next := fields size. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
677 |
] ifFalse:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
678 |
next > fields size ifTrue:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
679 |
next := 1 |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
680 |
] |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
681 |
]. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
682 |
next == thisIndex ifTrue:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
683 |
nextField := next := nil |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
684 |
] ifFalse:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
685 |
nextField := fields at:next. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
686 |
] |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
687 |
]. |
661 | 688 |
|
5062 | 689 |
next isNil ifTrue:[ |
690 |
(wg := currentField windowGroup) notNil ifTrue:[ |
|
4163 | 691 |
delta < 0 ifTrue:[ |
5062 | 692 |
wg focusPreviousFrom:aField |
693 |
] ifFalse:[ |
|
694 |
wg focusNextFrom:aField. |
|
4163 | 695 |
]. |
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
696 |
]. |
5062 | 697 |
^ self. |
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
698 |
]. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
699 |
|
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
700 |
nextField := fields at:next. |
661 | 701 |
explicit := false. |
4163 | 702 |
wg notNil ifTrue:[ |
661 | 703 |
wg focusView == currentField ifTrue:[ |
704 |
explicit := true. |
|
705 |
] |
|
706 |
]. |
|
707 |
explicit ifTrue:[ |
|
1798 | 708 |
wg focusView:nextField byTab:(wg focusCameByTab). |
661 | 709 |
] ifFalse:[ |
710 |
self makeActive:nextField |
|
711 |
] |
|
712 |
] |
|
713 |
||
4163 | 714 |
"Created: / 18-10-1997 / 03:03:34 / cg" |
715 |
"Modified: / 18-09-1998 / 20:16:48 / cg" |
|
716 |
"Modified: / 24-08-2010 / 16:14:17 / az" |
|
661 | 717 |
! ! |
718 |
||
121 | 719 |
!EnterFieldGroup methodsFor:'misc'! |
720 |
||
721 |
activateFirst |
|
5059 | 722 |
"pass control to my first field" |
121 | 723 |
|
724 |
fields notNil ifTrue:[ |
|
322 | 725 |
self makeActive:fields first |
121 | 726 |
] |
322 | 727 |
|
728 |
"Modified: 7.2.1996 / 15:23:09 / cg" |
|
675 | 729 |
! |
730 |
||
1647
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
731 |
activateFirstIfNoCurrent |
5059 | 732 |
"pass control to my first field, if there is no current field" |
1647
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
733 |
|
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
734 |
currentField isNil ifTrue:[ |
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
735 |
self activateFirst |
1793 | 736 |
] ifFalse:[ |
737 |
currentField requestFocus |
|
1647
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
738 |
] |
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
739 |
|
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
740 |
"Created: / 13.8.1998 / 21:22:35 / cg" |
1793 | 741 |
"Modified: / 15.3.1999 / 08:22:18 / cg" |
1647
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
742 |
! |
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
743 |
|
675 | 744 |
activateLast |
5059 | 745 |
"pass control to my last field" |
675 | 746 |
|
747 |
fields notNil ifTrue:[ |
|
748 |
self makeActive:fields last |
|
749 |
] |
|
750 |
||
751 |
"Modified: 7.2.1996 / 15:23:09 / cg" |
|
752 |
"Created: 22.5.1996 / 19:04:05 / cg" |
|
753 |
! |
|
754 |
||
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
755 |
delegatesTo:aView |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
756 |
^ aView == currentField |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
757 |
|
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
758 |
"Created: / 18.9.1998 / 19:57:49 / cg" |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
759 |
"Modified: / 18.9.1998 / 19:58:23 / cg" |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
760 |
! |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
761 |
|
7 | 762 |
makeActive:aField |
121 | 763 |
"make a specific field the active one" |
764 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
765 |
currentField == aField ifTrue:[^ self]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
766 |
|
7 | 767 |
currentField notNil ifTrue:[ |
596 | 768 |
currentField hideCursor. |
769 |
currentField hasKeyboardFocus:false. |
|
7 | 770 |
]. |
771 |
currentField := aField. |
|
121 | 772 |
currentField showCursor. |
773 |
currentField hasKeyboardFocus:true. |
|
596 | 774 |
|
661 | 775 |
"Modified: 21.5.1996 / 21:21:07 / cg" |
776 |
! |
|
777 |
||
5059 | 778 |
makeInactive |
779 |
"make the current field inActive (take its focus)" |
|
780 |
||
781 |
self makeInactive:currentField |
|
782 |
||
783 |
"Created: 22.5.1996 / 18:58:56 / cg" |
|
784 |
"Modified: 22.5.1996 / 19:03:44 / cg" |
|
785 |
! |
|
786 |
||
661 | 787 |
makeInactive:aField |
788 |
"make a specific field inActive" |
|
789 |
||
790 |
currentField == aField ifTrue:[currentField := nil]. |
|
791 |
||
792 |
aField notNil ifTrue:[ |
|
793 |
aField hideCursor. |
|
794 |
aField hasKeyboardFocus:false. |
|
795 |
]. |
|
796 |
||
797 |
"Created: 21.5.1996 / 21:20:57 / cg" |
|
121 | 798 |
! ! |
7 | 799 |
|
1355 | 800 |
!EnterFieldGroup class methodsFor:'documentation'! |
203 | 801 |
|
802 |
version |
|
5062 | 803 |
^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.43 2014-06-13 21:06:48 cg Exp $' |
4163 | 804 |
! |
805 |
||
806 |
version_CVS |
|
5062 | 807 |
^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.43 2014-06-13 21:06:48 cg Exp $' |
203 | 808 |
! ! |
5059 | 809 |