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