author | ca |
Fri, 02 Mar 2007 15:59:35 +0100 | |
changeset 3457 | 2684f36d5021 |
parent 2144 | 8cfc21c91319 |
child 4163 | 59799aef0498 |
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 |
|
278 | 422 |
fields |
423 |
"return a collection of the inputFields contained in the group." |
|
122 | 424 |
|
278 | 425 |
^ fields |
426 |
! |
|
199 | 427 |
|
428 |
leaveAction:aBlock |
|
429 |
"set the action to perform when the last field is left. |
|
430 |
Usually, this is to accept the values of all fields and perform |
|
431 |
some additional processing (such as closing a dialog)." |
|
432 |
||
433 |
leaveAction := aBlock |
|
434 |
! |
|
435 |
||
589 | 436 |
leaveOnTabLast:aBoolean |
437 |
"specifies if leaving the last field via Tab |
|
438 |
should leave the group or stay in the group. |
|
439 |
(if staying, either wrap or not, depending on the setting of wrap) |
|
440 |
The default is to stay in the group" |
|
441 |
||
442 |
leaveOnTabLast := aBoolean |
|
443 |
||
444 |
"Created: 27.4.1996 / 17:22:30 / cg" |
|
445 |
"Modified: 27.4.1996 / 17:22:44 / cg" |
|
446 |
! |
|
447 |
||
448 |
makeAllTabable |
|
449 |
"make all fields tabable" |
|
450 |
||
451 |
fields do:[:field | |
|
452 |
field makeTabable |
|
453 |
] |
|
454 |
||
455 |
"Created: 27.4.1996 / 17:11:41 / cg" |
|
456 |
! |
|
457 |
||
199 | 458 |
wrap:aBoolean |
278 | 459 |
"specifies if leaving the last field via non-Return |
589 | 460 |
(i.e. Tab or Cursor-Down) should wrap back to the first, |
461 |
or leave the group. |
|
462 |
The default is to not leave the group and wrap back to the first field." |
|
199 | 463 |
|
464 |
wrap := aBoolean |
|
589 | 465 |
|
466 |
"Modified: 27.4.1996 / 17:19:50 / cg" |
|
199 | 467 |
! ! |
468 |
||
2144 | 469 |
!EnterFieldGroup methodsFor:'adding & removing'! |
0 | 470 |
|
471 |
add:aField |
|
1355 | 472 |
"add another field to the group. |
473 |
Cursor motion out of the previous field will lead to the next |
|
474 |
one and vice versa." |
|
475 |
||
476 |
self add:aField before:nil |
|
477 |
||
478 |
"Modified: 18.10.1997 / 03:19:51 / cg" |
|
479 |
! |
|
480 |
||
481 |
add:aField before:anotherField |
|
482 |
"add another field to the group into a particular position |
|
483 |
within the tabbing order. |
|
484 |
Cursor motion out of the previous field will lead to the next |
|
485 |
one and vice versa." |
|
0 | 486 |
|
487 |
fields isNil ifTrue:[ |
|
589 | 488 |
fields := OrderedCollection new |
0 | 489 |
]. |
1355 | 490 |
|
491 |
anotherField isNil ifTrue:[ |
|
492 |
fields add:aField. |
|
493 |
] ifFalse:[ |
|
494 |
fields add:aField before:anotherField |
|
495 |
]. |
|
121 | 496 |
|
7 | 497 |
aField delegate:self. |
121 | 498 |
aField hideCursor. |
596 | 499 |
"/ aField disable. |
0 | 500 |
|
501 |
"set the fields enableAction to disable active field" |
|
502 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
503 |
aField clickAction:[:field | |
589 | 504 |
self makeActive:field |
0 | 505 |
]. |
506 |
||
507 |
"set the fields leaveAction to enable next field" |
|
508 |
||
1795 | 509 |
aField leaveAction:[:field :key | |
510 |
self fieldLeft:field withKey:key |
|
121 | 511 |
]. |
512 |
||
513 |
fields size == 1 ifTrue:[ |
|
589 | 514 |
"the first one" |
515 |
self makeActive:aField |
|
0 | 516 |
] |
589 | 517 |
|
1355 | 518 |
"Created: 18.10.1997 / 03:06:00 / cg" |
519 |
"Modified: 18.10.1997 / 03:20:36 / cg" |
|
520 |
! |
|
521 |
||
522 |
remove:aField |
|
523 |
"remove a field from the group." |
|
524 |
||
525 |
fields isNil ifTrue:[^ self]. |
|
526 |
(fields includesIdentical:aField) ifFalse:[^ self]. |
|
527 |
||
528 |
fields removeIdentical:aField. |
|
529 |
||
530 |
"Created: 18.10.1997 / 02:53:29 / cg" |
|
531 |
"Modified: 18.10.1997 / 03:21:09 / cg" |
|
0 | 532 |
! ! |
533 |
||
199 | 534 |
!EnterFieldGroup methodsFor:'event forwarding'! |
535 |
||
536 |
buttonPress:button x:x y:y view:aView |
|
537 |
"clicking on a field activates it and forwards the click to it" |
|
538 |
||
539 |
self makeActive:aView. |
|
540 |
aView buttonPress:button x:x y:y |
|
541 |
! |
|
542 |
||
543 |
handlesButtonPress:button inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
544 |
"query from event processor: am I interested in button-events ? |
199 | 545 |
yes I am (to activate the clicked-on field)." |
122 | 546 |
|
199 | 547 |
^ true |
548 |
! |
|
549 |
||
550 |
handlesKeyPress:key inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
551 |
"query from event processor: am I interested in key-events ? |
199 | 552 |
yes I am (to forward it to the active field)." |
553 |
||
554 |
^ true |
|
555 |
! |
|
556 |
||
557 |
handlesKeyRelease:key inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
558 |
"query from event processor: am I interested in key-events ? |
199 | 559 |
yes I am (to forward it to the active field)." |
560 |
||
561 |
^ true |
|
562 |
! |
|
121 | 563 |
|
199 | 564 |
keyPress:key x:x y:y view:aView |
565 |
"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
|
566 |
(with nil coordinates to indicate that the key was pressed |
199 | 567 |
outside. However, this info is not used by any view currently)" |
568 |
||
569 |
currentField notNil ifTrue:[ |
|
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
570 |
currentField keyPress:key x:nil y:nil |
199 | 571 |
] |
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
572 |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
573 |
"Modified: / 18.9.1998 / 20:00:36 / cg" |
199 | 574 |
! |
575 |
||
576 |
keyRelease:key x:x y:y view:aView |
|
577 |
"key-release in any field - forward the key to the active field. |
|
578 |
(with -1/-1 as coordinate to indicate that the key was pressed |
|
579 |
outside. However, this info is not used by any view currently)" |
|
580 |
||
581 |
currentField notNil ifTrue:[ |
|
582 |
currentField keyRelease:key x:-1 y:-1 |
|
583 |
] |
|
589 | 584 |
! |
585 |
||
586 |
showFocus:onOrOff |
|
587 |
"forward focus display to the active field " |
|
588 |
||
589 |
currentField notNil ifTrue:[ |
|
590 |
currentField showFocus:onOrOff |
|
591 |
] |
|
592 |
||
593 |
"Modified: 4.3.1996 / 22:18:22 / cg" |
|
594 |
"Created: 27.4.1996 / 16:41:38 / cg" |
|
595 |
! |
|
596 |
||
597 |
showNoFocus:onOrOff |
|
598 |
"forward nofocus display to the active field " |
|
599 |
||
600 |
currentField notNil ifTrue:[ |
|
601 |
currentField showNoFocus:onOrOff |
|
602 |
] |
|
603 |
||
604 |
"Modified: 4.3.1996 / 22:18:22 / cg" |
|
605 |
"Created: 27.4.1996 / 16:42:07 / cg" |
|
0 | 606 |
! ! |
607 |
||
661 | 608 |
!EnterFieldGroup methodsFor:'group control'! |
609 |
||
1355 | 610 |
fieldLeft:aField withKey:key |
1373 | 611 |
"some of my fields was left using key. |
612 |
Figure out, which one to give the focus: |
|
613 |
If there are more fields, go to that one; |
|
614 |
otherwise, handle this like tabbing to the next component" |
|
615 |
||
3457 | 616 |
|thisIndex action next wg explicit nFields nextField delta| |
661 | 617 |
|
618 |
action := key. |
|
619 |
nFields := fields size. |
|
1355 | 620 |
thisIndex := fields indexOf:aField. |
661 | 621 |
|
622 |
((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
|
623 |
delta := -1. |
661 | 624 |
(thisIndex == 1) ifTrue:[ |
625 |
next := nFields |
|
626 |
] ifFalse:[ |
|
627 |
next := thisIndex - 1 |
|
628 |
] |
|
629 |
]. |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
630 |
|
661 | 631 |
((key == #CursorDown) |
632 |
or:[key == #NextField |
|
633 |
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
|
634 |
delta := 1. |
661 | 635 |
(thisIndex == nFields) ifTrue:[ |
636 |
next := 1. |
|
637 |
wrap == false ifTrue:[ |
|
638 |
action := #Return. |
|
639 |
]. |
|
640 |
] ifFalse:[ |
|
641 |
next := thisIndex + 1 |
|
642 |
] |
|
643 |
]. |
|
644 |
((action == #Return) |
|
645 |
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
|
646 |
delta := 1. |
661 | 647 |
(thisIndex == nFields) ifTrue:[ |
648 |
leaveAction notNil ifTrue:[ |
|
649 |
self makeInactive:aField. |
|
650 |
currentField := nil. |
|
651 |
leaveAction value. |
|
652 |
next := nil |
|
653 |
] ifFalse:[ |
|
654 |
next := 1 |
|
655 |
] |
|
656 |
] ifFalse:[ |
|
657 |
next := thisIndex + 1 |
|
658 |
] |
|
659 |
]. |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
660 |
|
661 | 661 |
next notNil ifTrue:[ |
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
662 |
"/ 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
|
663 |
|
661 | 664 |
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
|
665 |
[nextField notNil |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
666 |
and:[nextField enabled not |
2028
4f5c00067ee7
when checking for realized fields, ask via #reallyRealized;
Claus Gittinger <cg@exept.de>
parents:
1798
diff
changeset
|
667 |
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
|
668 |
next := next + delta. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
669 |
next < 1 ifTrue:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
670 |
next := fields size. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
671 |
] ifFalse:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
672 |
next > fields size ifTrue:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
673 |
next := 1 |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
674 |
] |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
675 |
]. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
676 |
next == thisIndex ifTrue:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
677 |
nextField := next := nil |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
678 |
] ifFalse:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
679 |
nextField := fields at:next. |
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 |
]. |
661 | 682 |
|
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
683 |
next isNil ifTrue:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
684 |
delta < 0 ifTrue:[ |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
685 |
^ wg focusPreviousFrom:aField |
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 |
^ wg focusNextFrom:aField. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
688 |
]. |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
689 |
|
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
690 |
nextField := fields at:next. |
661 | 691 |
explicit := false. |
692 |
(wg := currentField windowGroup) notNil ifTrue:[ |
|
693 |
wg focusView == currentField ifTrue:[ |
|
694 |
explicit := true. |
|
695 |
] |
|
696 |
]. |
|
697 |
explicit ifTrue:[ |
|
1798 | 698 |
wg focusView:nextField byTab:(wg focusCameByTab). |
661 | 699 |
] ifFalse:[ |
700 |
self makeActive:nextField |
|
701 |
] |
|
702 |
] |
|
703 |
||
1373 | 704 |
"Created: / 18.10.1997 / 03:03:34 / cg" |
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
705 |
"Modified: / 18.9.1998 / 20:16:48 / cg" |
661 | 706 |
! ! |
707 |
||
121 | 708 |
!EnterFieldGroup methodsFor:'misc'! |
709 |
||
710 |
activateFirst |
|
711 |
"pass controll to my first field" |
|
712 |
||
713 |
fields notNil ifTrue:[ |
|
322 | 714 |
self makeActive:fields first |
121 | 715 |
] |
322 | 716 |
|
717 |
"Modified: 7.2.1996 / 15:23:09 / cg" |
|
675 | 718 |
! |
719 |
||
1647
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
720 |
activateFirstIfNoCurrent |
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
721 |
"pass controll to my first field, if there is no current field" |
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
722 |
|
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
723 |
currentField isNil ifTrue:[ |
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
724 |
self activateFirst |
1793 | 725 |
] ifFalse:[ |
726 |
currentField requestFocus |
|
1647
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
727 |
] |
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
728 |
|
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
729 |
"Created: / 13.8.1998 / 21:22:35 / cg" |
1793 | 730 |
"Modified: / 15.3.1999 / 08:22:18 / cg" |
1647
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
731 |
! |
55d802bae8eb
added #activateFirstIfNoCurrent
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
732 |
|
675 | 733 |
activateLast |
734 |
"pass controll to my last field" |
|
735 |
||
736 |
fields notNil ifTrue:[ |
|
737 |
self makeActive:fields last |
|
738 |
] |
|
739 |
||
740 |
"Modified: 7.2.1996 / 15:23:09 / cg" |
|
741 |
"Created: 22.5.1996 / 19:04:05 / cg" |
|
742 |
! |
|
743 |
||
1685
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
744 |
delegatesTo:aView |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
745 |
^ aView == currentField |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
746 |
|
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
747 |
"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
|
748 |
"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
|
749 |
! |
36c8fa86d629
skip disabled and invisible fields when stepping to next field
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
750 |
|
675 | 751 |
makeInactive |
752 |
"make the current field inActive (take its focus)" |
|
753 |
||
754 |
self makeInactive:currentField |
|
755 |
||
756 |
"Created: 22.5.1996 / 18:58:56 / cg" |
|
757 |
"Modified: 22.5.1996 / 19:03:44 / cg" |
|
121 | 758 |
! ! |
759 |
||
760 |
!EnterFieldGroup methodsFor:'private'! |
|
0 | 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 |
||
778 |
makeInactive:aField |
|
779 |
"make a specific field inActive" |
|
780 |
||
781 |
currentField == aField ifTrue:[currentField := nil]. |
|
782 |
||
783 |
aField notNil ifTrue:[ |
|
784 |
aField hideCursor. |
|
785 |
aField hasKeyboardFocus:false. |
|
786 |
]. |
|
787 |
||
788 |
"Created: 21.5.1996 / 21:20:57 / cg" |
|
121 | 789 |
! ! |
7 | 790 |
|
1355 | 791 |
!EnterFieldGroup class methodsFor:'documentation'! |
203 | 792 |
|
793 |
version |
|
3457 | 794 |
^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.40 2007-03-02 14:59:35 ca Exp $' |
203 | 795 |
! ! |