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