author | Claus Gittinger <cg@exept.de> |
Mon, 04 Mar 1996 23:32:09 +0100 | |
changeset 466 | e878bd3b227e |
parent 322 | 3a25112b58b1 |
child 581 | 4d48caecf4a0 |
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 |
278 | 14 |
instanceVariableNames:'fields currentField leaveAction wrap' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-Support' |
|
0 | 18 |
! |
19 |
||
38 | 20 |
!EnterFieldGroup class methodsFor:'documentation'! |
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 |
|
42 |
to the active field (having the inputField delegate its input to me). |
|
43 |
||
38 | 44 |
The block accessable as leaveAction is evaluated when the last |
121 | 45 |
field of the group is left (by cursor-down or cr). |
46 |
Usually this block triggers accept on the fields and/or performs some |
|
47 |
followup processing and closes the topview (for example: in a dialog). |
|
122 | 48 |
|
49 |
EnterFieldGroups can be used as a delegate (of the topView) to forward |
|
50 |
input (entered into the topView) to the currently active field. |
|
51 |
||
52 |
Stepping to previous field is via CursorUp/PreviousField, |
|
53 |
to next field via CursorDown/NextField/Tab. |
|
54 |
Notice, that by default, the editField takes the tab-character as |
|
55 |
a normal character. To step using tab, you have to add the Tab key to the |
|
56 |
fields leaveKeys. |
|
57 |
||
58 |
Instance variables: |
|
59 |
||
60 |
fields <Collection of EditField> the fields of the group |
|
61 |
||
62 |
currentField <EditField> the active field |
|
63 |
||
64 |
leaveAction <nil|Block> action to perform, when the |
|
65 |
last field is left by a non-wrap |
|
66 |
||
67 |
wrap <Boolean> if true, non-return next-keys wrap |
|
68 |
back to the first field. |
|
69 |
If false (the default), next in |
|
70 |
the last field is taken as return. |
|
71 |
This is ignored, if no leaveAction was |
|
72 |
defined. |
|
121 | 73 |
" |
74 |
! |
|
75 |
||
76 |
examples |
|
77 |
" |
|
122 | 78 |
without a group - user has to enter mouse into the next field to activate it; |
79 |
Cursor-keys dont work: |
|
121 | 80 |
|
81 |
|top panel field1 field2 field3| |
|
82 |
||
83 |
top := StandardSystemView new. |
|
84 |
top extent:200@200. |
|
85 |
||
86 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
87 |
||
88 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
|
89 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
90 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
91 |
||
92 |
top open |
|
93 |
||
94 |
||
95 |
with a group - Return-key or CursorKey enables next field: |
|
122 | 96 |
(but still, mouse pointer has to be moved into any of the fields, |
97 |
because the topView does not forward its input into the fields) |
|
121 | 98 |
|
99 |
|top panel group field1 field2 field3| |
|
100 |
||
101 |
top := StandardSystemView new. |
|
102 |
top extent:200@200. |
|
103 |
||
104 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
105 |
||
106 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
|
107 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
108 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
109 |
||
110 |
group := EnterFieldGroup new. |
|
111 |
group add:field1; add:field2; add:field3. |
|
112 |
||
113 |
top open |
|
114 |
||
115 |
||
116 |
||
122 | 117 |
same, enables tabbing via the Tab key: |
118 |
||
119 |
|top panel group field1 field2 field3| |
|
120 |
||
121 |
top := StandardSystemView new. |
|
122 |
top extent:200@200. |
|
123 |
||
124 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
125 |
||
126 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
|
127 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
128 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
129 |
||
130 |
group := EnterFieldGroup new. |
|
131 |
group add:field1; add:field2; add:field3. |
|
132 |
||
133 |
field1 leaveKeys:(EditField defaultLeaveKeys copyWith:#Tab). |
|
134 |
field2 leaveKeys:(EditField defaultLeaveKeys copyWith:#Tab). |
|
135 |
field3 leaveKeys:(EditField defaultLeaveKeys copyWith:#Tab). |
|
136 |
top open |
|
137 |
||
138 |
||
139 |
||
140 |
with a group - Return-key or CursorKey enables next field: |
|
141 |
input into topView is forwarded to the group: |
|
142 |
||
143 |
|top panel group field1 field2 field3| |
|
144 |
||
145 |
top := StandardSystemView new. |
|
146 |
top extent:200@200. |
|
147 |
||
148 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
149 |
||
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. |
|
156 |
||
157 |
top delegate:group. |
|
158 |
top open |
|
159 |
||
160 |
||
161 |
||
162 |
as above, but close the box when the last field is left: |
|
163 |
||
164 |
|top panel group field1 field2 field3| |
|
165 |
||
166 |
top := StandardSystemView new. |
|
167 |
top extent:200@200. |
|
168 |
||
169 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
170 |
||
171 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
|
172 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
173 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
174 |
||
175 |
group := EnterFieldGroup new. |
|
176 |
group add:field1; add:field2; add:field3. |
|
177 |
group leaveAction:[top destroy]. |
|
178 |
||
179 |
top delegate:group. |
|
180 |
top open |
|
181 |
||
182 |
||
183 |
||
184 |
same as above, with Tab-key stepping: |
|
121 | 185 |
|
186 |
|top panel group field1 field2 field3| |
|
187 |
||
188 |
top := StandardSystemView new. |
|
189 |
top extent:200@200. |
|
190 |
||
191 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
192 |
||
193 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
|
194 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
195 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
196 |
||
197 |
group := EnterFieldGroup new. |
|
198 |
group add:field1; add:field2; add:field3. |
|
199 |
group leaveAction:[top destroy]. |
|
200 |
||
122 | 201 |
field1 leaveKeys:(EditField defaultLeaveKeys copyWith:#Tab). |
202 |
field2 leaveKeys:(EditField defaultLeaveKeys copyWith:#Tab). |
|
203 |
field3 leaveKeys:(EditField defaultLeaveKeys copyWith:#Tab). |
|
204 |
||
205 |
top delegate:group. |
|
121 | 206 |
top open |
122 | 207 |
|
208 |
||
209 |
||
210 |
the next example shows that the input order is defined by the |
|
211 |
order in the group; NOT by the physical layout of the fields in the superview: |
|
130 | 212 |
(i.e. you can arrange your fields in multiple framedBoxes, panels or |
213 |
subviews - independent of the tab-stepping order) |
|
122 | 214 |
|
215 |
|top panel group field1 field2 field3| |
|
216 |
||
217 |
top := StandardSystemView new. |
|
218 |
top extent:200@200. |
|
219 |
||
220 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
221 |
||
222 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
|
223 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
224 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
225 |
||
226 |
group := EnterFieldGroup new. |
|
227 |
group add:field3; add:field2; add:field1. |
|
228 |
group leaveAction:[top destroy]. |
|
229 |
||
230 |
top delegate:group. |
|
231 |
top open |
|
232 |
||
233 |
||
234 |
||
235 |
using a single model for all fields: |
|
236 |
(here, we use a Plug to simulate a more complex model): |
|
237 |
||
238 |
|top panel group field1 field2 field3 model |
|
239 |
value1 value2 value3| |
|
240 |
||
241 |
top := StandardSystemView new. |
|
242 |
top extent:200@200. |
|
243 |
||
244 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
245 |
||
246 |
panel add:(field1 := EditField extent:(1.0 @ nil)). |
|
247 |
panel add:(field2 := EditField extent:(1.0 @ nil)). |
|
248 |
panel add:(field3 := EditField extent:(1.0 @ nil)). |
|
249 |
||
250 |
group := EnterFieldGroup new. |
|
251 |
group add:field1; add:field2; add:field3. |
|
252 |
group leaveAction:[top destroy]. |
|
253 |
||
254 |
value1 := 'one'. value2 := 'two'. value3 := 'three'. |
|
255 |
||
256 |
model := Plug new. |
|
257 |
model respondTo:#value1 with:[value1]. |
|
258 |
model respondTo:#value1: with:[:arg | value1 := arg]. |
|
259 |
model respondTo:#value2 with:[value2]. |
|
260 |
model respondTo:#value2: with:[:arg | value2 := arg]. |
|
261 |
model respondTo:#value3 with:[value3]. |
|
262 |
model respondTo:#value3: with:[:arg | value3 := arg]. |
|
263 |
||
264 |
field1 model:model; aspect:#value1; change:#value1:. |
|
265 |
field2 model:model; aspect:#value2; change:#value2:. |
|
266 |
field3 model:model; aspect:#value3; change:#value3:. |
|
267 |
||
268 |
top delegate:group. |
|
269 |
top openModal. |
|
270 |
||
271 |
Transcript showCr:'value1: ' , value1. |
|
272 |
Transcript showCr:'value2: ' , value2. |
|
273 |
Transcript showCr:'value3: ' , value3. |
|
274 |
||
275 |
||
276 |
the above is done automatically for you, if you add inputFields |
|
277 |
to a dialogBox: |
|
278 |
||
279 |
|box model |
|
280 |
value1 value2 value3| |
|
281 |
||
282 |
box := DialogBox new. |
|
283 |
box extent:200@200. |
|
284 |
||
285 |
value1 := 'one'. value2 := 'two'. value3 := 'three'. |
|
286 |
||
287 |
model := Plug new. |
|
288 |
model respondTo:#value1 with:[value1]. |
|
289 |
model respondTo:#value1: with:[:arg | value1 := arg]. |
|
290 |
model respondTo:#value2 with:[value2]. |
|
291 |
model respondTo:#value2: with:[:arg | value2 := arg]. |
|
292 |
model respondTo:#value3 with:[value3]. |
|
293 |
model respondTo:#value3: with:[:arg | value3 := arg]. |
|
294 |
||
295 |
(box addInputFieldOn:model) aspect:#value1; change:#value1:. |
|
296 |
box addVerticalSpace. |
|
297 |
(box addInputFieldOn:model) aspect:#value2; change:#value2:. |
|
298 |
box addVerticalSpace. |
|
299 |
(box addInputFieldOn:model) aspect:#value3; change:#value3:. |
|
300 |
||
301 |
box open. |
|
302 |
||
303 |
Transcript showCr:'value1: ' , value1. |
|
304 |
Transcript showCr:'value2: ' , value2. |
|
305 |
Transcript showCr:'value3: ' , value3. |
|
38 | 306 |
" |
307 |
! ! |
|
0 | 308 |
|
278 | 309 |
!EnterFieldGroup methodsFor:'accessing'! |
122 | 310 |
|
278 | 311 |
fields |
312 |
"return a collection of the inputFields contained in the group." |
|
122 | 313 |
|
278 | 314 |
^ fields |
315 |
! |
|
199 | 316 |
|
317 |
leaveAction:aBlock |
|
318 |
"set the action to perform when the last field is left. |
|
319 |
Usually, this is to accept the values of all fields and perform |
|
320 |
some additional processing (such as closing a dialog)." |
|
321 |
||
322 |
leaveAction := aBlock |
|
323 |
! |
|
324 |
||
325 |
wrap:aBoolean |
|
278 | 326 |
"specifies if leaving the last field via non-Return |
327 |
should wrap back to the first, or leave the group. |
|
328 |
The default is to stay in the input sequence and wrap back to |
|
329 |
the first field." |
|
199 | 330 |
|
331 |
wrap := aBoolean |
|
332 |
! ! |
|
333 |
||
0 | 334 |
!EnterFieldGroup methodsFor:'adding / removing'! |
335 |
||
336 |
add:aField |
|
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
337 |
|thisIndex action| |
0 | 338 |
|
339 |
fields isNil ifTrue:[ |
|
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
340 |
fields := OrderedCollection new |
0 | 341 |
]. |
342 |
fields add:aField. |
|
343 |
thisIndex := fields size. |
|
121 | 344 |
|
7 | 345 |
aField delegate:self. |
121 | 346 |
aField hideCursor. |
0 | 347 |
aField disable. |
348 |
||
349 |
"set the fields enableAction to disable active field" |
|
350 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
351 |
aField clickAction:[:field | |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
352 |
self makeActive:field |
0 | 353 |
]. |
354 |
||
355 |
"set the fields leaveAction to enable next field" |
|
356 |
||
357 |
aField leaveAction:[:key | |
|
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
358 |
|next wg explicit nFields nextField| |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
359 |
|
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
360 |
"/ currentField notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
361 |
"/ currentField disable. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
362 |
"/ currentField hideCursor. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
363 |
"/ ]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
364 |
"/ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
365 |
action := key. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
366 |
nFields := fields size. |
122 | 367 |
|
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
368 |
((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
369 |
(thisIndex == 1) ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
370 |
next := nFields |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
371 |
] ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
372 |
next := thisIndex - 1 |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
373 |
] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
374 |
]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
375 |
((key == #CursorDown) |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
376 |
or:[key == #NextField |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
377 |
or:[key == #Tab]]) ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
378 |
(thisIndex == nFields) ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
379 |
next := 1. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
380 |
wrap == false ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
381 |
action := #Return. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
382 |
]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
383 |
] ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
384 |
next := thisIndex + 1 |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
385 |
] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
386 |
]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
387 |
(action == #Return) ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
388 |
(thisIndex == nFields) ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
389 |
leaveAction notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
390 |
currentField := nil. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
391 |
leaveAction value. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
392 |
next := nil |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
393 |
] ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
394 |
next := 1 |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
395 |
] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
396 |
] ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
397 |
next := thisIndex + 1 |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
398 |
] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
399 |
]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
400 |
next notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
401 |
nextField := fields at:next. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
402 |
|
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
403 |
explicit := false. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
404 |
(wg := currentField windowGroup) notNil ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
405 |
wg focusView == currentField ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
406 |
explicit := true. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
407 |
] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
408 |
]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
409 |
explicit ifTrue:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
410 |
wg focusView:nextField. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
411 |
] ifFalse:[ |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
412 |
self makeActive:nextField |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
413 |
] |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
414 |
] |
121 | 415 |
]. |
416 |
||
417 |
fields size == 1 ifTrue:[ |
|
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
418 |
"the first one" |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
419 |
self makeActive:aField |
0 | 420 |
] |
421 |
! ! |
|
422 |
||
199 | 423 |
!EnterFieldGroup methodsFor:'event forwarding'! |
424 |
||
425 |
buttonPress:button x:x y:y view:aView |
|
426 |
"clicking on a field activates it and forwards the click to it" |
|
427 |
||
428 |
self makeActive:aView. |
|
429 |
aView buttonPress:button x:x y:y |
|
430 |
! |
|
431 |
||
432 |
buttonShiftPress:button x:x y:y view:aView |
|
433 |
"clicking on a field activates it and forwards the click to it" |
|
0 | 434 |
|
199 | 435 |
self makeActive:aView. |
436 |
aView buttonShiftPress:button x:x y:y |
|
437 |
! |
|
438 |
||
439 |
handlesButtonPress:button inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
440 |
"query from event processor: am I interested in button-events ? |
199 | 441 |
yes I am (to activate the clicked-on field)." |
122 | 442 |
|
199 | 443 |
^ true |
444 |
! |
|
445 |
||
446 |
handlesButtonShiftPress:button inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
447 |
"query from event processor: am I interested in button-events ? |
199 | 448 |
yes I am (to activate the clicked-on field)." |
449 |
||
450 |
^ true |
|
122 | 451 |
! |
452 |
||
199 | 453 |
handlesKeyPress:key inView:aView |
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
454 |
"query from event processor: am I interested in key-events ? |
199 | 455 |
yes I am (to forward it to the active field)." |
456 |
||
457 |
^ true |
|
458 |
! |
|
459 |
||
460 |
handlesKeyRelease:key inView:aView |
|
258
ae4b8f1a6738
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
461 |
"query from event processor: am I interested in key-events ? |
199 | 462 |
yes I am (to forward it to the active field)." |
463 |
||
464 |
^ true |
|
465 |
! |
|
121 | 466 |
|
199 | 467 |
keyPress:key x:x y:y view:aView |
468 |
"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
|
469 |
(with nil coordinates to indicate that the key was pressed |
199 | 470 |
outside. However, this info is not used by any view currently)" |
471 |
||
472 |
currentField notNil ifTrue:[ |
|
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
473 |
currentField keyPress:key x:nil y:nil |
199 | 474 |
] |
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
475 |
|
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
476 |
"Modified: 4.3.1996 / 22:18:22 / cg" |
199 | 477 |
! |
478 |
||
479 |
keyRelease:key x:x y:y view:aView |
|
480 |
"key-release in any field - forward the key to the active field. |
|
481 |
(with -1/-1 as coordinate to indicate that the key was pressed |
|
482 |
outside. However, this info is not used by any view currently)" |
|
483 |
||
484 |
currentField notNil ifTrue:[ |
|
485 |
currentField keyRelease:key x:-1 y:-1 |
|
486 |
] |
|
0 | 487 |
! ! |
488 |
||
121 | 489 |
!EnterFieldGroup methodsFor:'misc'! |
490 |
||
491 |
activateFirst |
|
492 |
"pass controll to my first field" |
|
493 |
||
494 |
fields notNil ifTrue:[ |
|
322 | 495 |
self makeActive:fields first |
121 | 496 |
] |
322 | 497 |
|
498 |
"Modified: 7.2.1996 / 15:23:09 / cg" |
|
121 | 499 |
! ! |
500 |
||
501 |
!EnterFieldGroup methodsFor:'private'! |
|
0 | 502 |
|
7 | 503 |
makeActive:aField |
121 | 504 |
"make a specific field the active one" |
505 |
||
316
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
506 |
currentField == aField ifTrue:[^ self]. |
1e27aa926710
fixed Tab handling in enterFieldGroups;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
507 |
|
7 | 508 |
currentField notNil ifTrue:[ |
121 | 509 |
currentField disable. |
510 |
currentField hideCursor. |
|
511 |
currentField hasKeyboardFocus:false. |
|
7 | 512 |
]. |
513 |
currentField := aField. |
|
514 |
currentField enable. |
|
121 | 515 |
currentField showCursor. |
516 |
currentField hasKeyboardFocus:true. |
|
517 |
! ! |
|
7 | 518 |
|
203 | 519 |
!EnterFieldGroup class methodsFor:'documentation'! |
520 |
||
521 |
version |
|
466
e878bd3b227e
delegated keyboardMessages get nil as x/y
Claus Gittinger <cg@exept.de>
parents:
322
diff
changeset
|
522 |
^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.20 1996-03-04 22:32:09 cg Exp $' |
203 | 523 |
! ! |