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