author | Claus Gittinger <cg@exept.de> |
Fri, 25 Jul 1997 16:21:11 +0200 | |
changeset 1280 | 460131bb2a9a |
parent 809 | e8c93a70bfd1 |
child 1355 | 6725ab9cc6f5 |
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 |
||
809
e8c93a70bfd1
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
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 |
|
1280 | 471 |
|thisIndex| |
0 | 472 |
|
473 |
fields isNil ifTrue:[ |
|
589 | 474 |
fields := OrderedCollection new |
0 | 475 |
]. |
476 |
fields add:aField. |
|
477 |
thisIndex := fields size. |
|
121 | 478 |
|
7 | 479 |
aField delegate:self. |
121 | 480 |
aField hideCursor. |
596 | 481 |
"/ aField disable. |
0 | 482 |
|
483 |
"set the fields enableAction to disable active field" |
|
484 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
485 |
aField clickAction:[:field | |
589 | 486 |
self makeActive:field |
0 | 487 |
]. |
488 |
||
489 |
"set the fields leaveAction to enable next field" |
|
490 |
||
491 |
aField leaveAction:[:key | |
|
661 | 492 |
self fieldLeft:aField index:thisIndex withKey:key |
121 | 493 |
]. |
494 |
||
495 |
fields size == 1 ifTrue:[ |
|
589 | 496 |
"the first one" |
497 |
self makeActive:aField |
|
0 | 498 |
] |
589 | 499 |
|
661 | 500 |
"Modified: 21.5.1996 / 21:18:58 / cg" |
0 | 501 |
! ! |
502 |
||
199 | 503 |
!EnterFieldGroup methodsFor:'event forwarding'! |
504 |
||
505 |
buttonPress:button x:x y:y view:aView |
|
506 |
"clicking on a field activates it and forwards the click to it" |
|
507 |
||
508 |
self makeActive:aView. |
|
509 |
aView buttonPress:button x:x y:y |
|
510 |
! |
|
511 |
||
512 |
handlesButtonPress:button inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
513 |
"query from event processor: am I interested in button-events ? |
199 | 514 |
yes I am (to activate the clicked-on field)." |
122 | 515 |
|
199 | 516 |
^ true |
517 |
! |
|
518 |
||
519 |
handlesKeyPress:key inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
520 |
"query from event processor: am I interested in key-events ? |
199 | 521 |
yes I am (to forward it to the active field)." |
522 |
||
523 |
^ true |
|
524 |
! |
|
525 |
||
526 |
handlesKeyRelease:key inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
527 |
"query from event processor: am I interested in key-events ? |
199 | 528 |
yes I am (to forward it to the active field)." |
529 |
||
530 |
^ true |
|
531 |
! |
|
121 | 532 |
|
199 | 533 |
keyPress:key x:x y:y view:aView |
534 |
"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
|
535 |
(with nil coordinates to indicate that the key was pressed |
199 | 536 |
outside. However, this info is not used by any view currently)" |
537 |
||
538 |
currentField notNil ifTrue:[ |
|
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
539 |
currentField keyPress:key x:nil y:nil |
199 | 540 |
] |
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
541 |
|
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
542 |
"Modified: 4.3.1996 / 22:18:22 / cg" |
199 | 543 |
! |
544 |
||
545 |
keyRelease:key x:x y:y view:aView |
|
546 |
"key-release in any field - forward the key to the active field. |
|
547 |
(with -1/-1 as coordinate to indicate that the key was pressed |
|
548 |
outside. However, this info is not used by any view currently)" |
|
549 |
||
550 |
currentField notNil ifTrue:[ |
|
551 |
currentField keyRelease:key x:-1 y:-1 |
|
552 |
] |
|
589 | 553 |
! |
554 |
||
555 |
showFocus:onOrOff |
|
556 |
"forward focus display to the active field " |
|
557 |
||
558 |
currentField notNil ifTrue:[ |
|
559 |
currentField showFocus:onOrOff |
|
560 |
] |
|
561 |
||
562 |
"Modified: 4.3.1996 / 22:18:22 / cg" |
|
563 |
"Created: 27.4.1996 / 16:41:38 / cg" |
|
564 |
! |
|
565 |
||
566 |
showNoFocus:onOrOff |
|
567 |
"forward nofocus display to the active field " |
|
568 |
||
569 |
currentField notNil ifTrue:[ |
|
570 |
currentField showNoFocus:onOrOff |
|
571 |
] |
|
572 |
||
573 |
"Modified: 4.3.1996 / 22:18:22 / cg" |
|
574 |
"Created: 27.4.1996 / 16:42:07 / cg" |
|
0 | 575 |
! ! |
576 |
||
661 | 577 |
!EnterFieldGroup methodsFor:'group control'! |
578 |
||
579 |
fieldLeft:aField index:thisIndex withKey:key |
|
738
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
580 |
|action next wg explicit nFields nextField fs| |
661 | 581 |
|
582 |
"/ currentField notNil ifTrue:[ |
|
583 |
"/ currentField disable. |
|
584 |
"/ currentField hideCursor. |
|
585 |
"/ ]. |
|
586 |
"/ |
|
587 |
action := key. |
|
588 |
nFields := fields size. |
|
589 |
||
738
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
590 |
"/ 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
|
591 |
"/ 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
|
592 |
"/ focus. Otherwise, stay within the group. |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
593 |
|
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
594 |
((wg := aField windowGroup) notNil |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
595 |
and:[(fs := wg focusSequence) notNil |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
596 |
and:[fs includesIdentical:aField]]) ifTrue:[ |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
597 |
((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[ |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
598 |
(thisIndex == 1) ifTrue:[ |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
599 |
^ wg focusPrevious |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
600 |
]. |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
601 |
]. |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
602 |
((key == #CursorDown) |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
603 |
or:[key == #NextField |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
604 |
or:[key == #Tab]]) ifTrue:[ |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
605 |
(thisIndex == nFields) ifTrue:[ |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
606 |
^ wg focusNext |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
607 |
]. |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
608 |
]. |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
609 |
]. |
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
610 |
|
661 | 611 |
((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[ |
612 |
(thisIndex == 1) ifTrue:[ |
|
613 |
next := nFields |
|
614 |
] ifFalse:[ |
|
615 |
next := thisIndex - 1 |
|
616 |
] |
|
617 |
]. |
|
618 |
((key == #CursorDown) |
|
619 |
or:[key == #NextField |
|
620 |
or:[key == #Tab]]) ifTrue:[ |
|
621 |
(thisIndex == nFields) ifTrue:[ |
|
622 |
next := 1. |
|
623 |
wrap == false ifTrue:[ |
|
624 |
action := #Return. |
|
625 |
]. |
|
626 |
] ifFalse:[ |
|
627 |
next := thisIndex + 1 |
|
628 |
] |
|
629 |
]. |
|
630 |
((action == #Return) |
|
631 |
or:[key == #Tab and:[leaveOnTabLast == true]]) ifTrue:[ |
|
632 |
(thisIndex == nFields) ifTrue:[ |
|
633 |
leaveAction notNil ifTrue:[ |
|
634 |
self makeInactive:aField. |
|
635 |
currentField := nil. |
|
636 |
leaveAction value. |
|
637 |
next := nil |
|
638 |
] ifFalse:[ |
|
639 |
next := 1 |
|
640 |
] |
|
641 |
] ifFalse:[ |
|
642 |
next := thisIndex + 1 |
|
643 |
] |
|
644 |
]. |
|
645 |
next notNil ifTrue:[ |
|
646 |
nextField := fields at:next. |
|
647 |
||
648 |
explicit := false. |
|
649 |
(wg := currentField windowGroup) notNil ifTrue:[ |
|
650 |
wg focusView == currentField ifTrue:[ |
|
651 |
explicit := true. |
|
652 |
] |
|
653 |
]. |
|
654 |
explicit ifTrue:[ |
|
655 |
wg focusView:nextField. |
|
656 |
] ifFalse:[ |
|
657 |
self makeActive:nextField |
|
658 |
] |
|
659 |
] |
|
660 |
||
661 |
"Created: 21.5.1996 / 21:18:08 / cg" |
|
738
33308a6375e8
handle leave from group as a focus-step
Claus Gittinger <cg@exept.de>
parents:
675
diff
changeset
|
662 |
"Modified: 31.5.1996 / 21:35:31 / cg" |
661 | 663 |
! ! |
664 |
||
121 | 665 |
!EnterFieldGroup methodsFor:'misc'! |
666 |
||
667 |
activateFirst |
|
668 |
"pass controll to my first field" |
|
669 |
||
670 |
fields notNil ifTrue:[ |
|
322 | 671 |
self makeActive:fields first |
121 | 672 |
] |
322 | 673 |
|
674 |
"Modified: 7.2.1996 / 15:23:09 / cg" |
|
675 | 675 |
! |
676 |
||
677 |
activateLast |
|
678 |
"pass controll to my last field" |
|
679 |
||
680 |
fields notNil ifTrue:[ |
|
681 |
self makeActive:fields last |
|
682 |
] |
|
683 |
||
684 |
"Modified: 7.2.1996 / 15:23:09 / cg" |
|
685 |
"Created: 22.5.1996 / 19:04:05 / cg" |
|
686 |
! |
|
687 |
||
688 |
makeInactive |
|
689 |
"make the current field inActive (take its focus)" |
|
690 |
||
691 |
self makeInactive:currentField |
|
692 |
||
693 |
"Created: 22.5.1996 / 18:58:56 / cg" |
|
694 |
"Modified: 22.5.1996 / 19:03:44 / cg" |
|
121 | 695 |
! ! |
696 |
||
697 |
!EnterFieldGroup methodsFor:'private'! |
|
0 | 698 |
|
7 | 699 |
makeActive:aField |
121 | 700 |
"make a specific field the active one" |
701 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
702 |
currentField == aField ifTrue:[^ self]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
703 |
|
7 | 704 |
currentField notNil ifTrue:[ |
596 | 705 |
currentField hideCursor. |
706 |
currentField hasKeyboardFocus:false. |
|
7 | 707 |
]. |
708 |
currentField := aField. |
|
121 | 709 |
currentField showCursor. |
710 |
currentField hasKeyboardFocus:true. |
|
596 | 711 |
|
661 | 712 |
"Modified: 21.5.1996 / 21:21:07 / cg" |
713 |
! |
|
714 |
||
715 |
makeInactive:aField |
|
716 |
"make a specific field inActive" |
|
717 |
||
718 |
currentField == aField ifTrue:[currentField := nil]. |
|
719 |
||
720 |
aField notNil ifTrue:[ |
|
721 |
aField hideCursor. |
|
722 |
aField hasKeyboardFocus:false. |
|
723 |
]. |
|
724 |
||
725 |
"Created: 21.5.1996 / 21:20:57 / cg" |
|
121 | 726 |
! ! |
7 | 727 |
|
809
e8c93a70bfd1
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
728 |
!EnterFieldGroup class methodsFor:'documentation'! |
203 | 729 |
|
730 |
version |
|
1280 | 731 |
^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.29 1997-07-25 14:20:49 cg Exp $' |
203 | 732 |
! ! |