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