0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
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
|
0
|
14 |
instanceVariableNames:'fields currentField leaveAction'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
EnterFieldGroup comment:'
|
5
|
21 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
0
|
22 |
All Rights Reserved
|
|
23 |
|
38
|
24 |
$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.5 1994-08-07 13:21:19 claus Exp $
|
|
25 |
'!
|
|
26 |
|
|
27 |
!EnterFieldGroup class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
|
32 |
All Rights Reserved
|
0
|
33 |
|
38
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
|
45 |
$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.5 1994-08-07 13:21:19 claus Exp $
|
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
EnterFieldGroup controlls the interaction between EnterFields
|
|
52 |
enabling next/prev field when a field is left. Instances of
|
|
53 |
this class keep track of which field of the group is the currentField
|
|
54 |
(i.e. the one getting keyboard input).
|
|
55 |
The block accessable as leaveAction is evaluated when the last
|
|
56 |
field of the group is left (by cursor-down or cr). Usually this block
|
|
57 |
triggers some action on the fields.
|
|
58 |
"
|
|
59 |
! !
|
0
|
60 |
|
|
61 |
!EnterFieldGroup methodsFor:'adding / removing'!
|
|
62 |
|
|
63 |
add:aField
|
|
64 |
|thisIndex next|
|
|
65 |
|
|
66 |
fields isNil ifTrue:[
|
|
67 |
fields := OrderedCollection new
|
|
68 |
].
|
|
69 |
fields add:aField.
|
|
70 |
thisIndex := fields size.
|
7
|
71 |
aField delegate:self.
|
0
|
72 |
aField disable.
|
|
73 |
|
|
74 |
"set the fields enableAction to disable active field"
|
|
75 |
|
|
76 |
aField enableAction:[
|
|
77 |
currentField notNil ifTrue:[
|
|
78 |
currentField disable
|
|
79 |
].
|
|
80 |
currentField := aField
|
|
81 |
].
|
|
82 |
|
|
83 |
"set the fields leaveAction to enable next field"
|
|
84 |
|
|
85 |
aField leaveAction:[:key |
|
|
86 |
currentField notNil ifTrue:[
|
|
87 |
currentField disable
|
|
88 |
].
|
|
89 |
(key == #Up) ifTrue:[
|
|
90 |
(thisIndex == 1) ifTrue:[
|
|
91 |
next := fields size
|
|
92 |
] ifFalse:[
|
|
93 |
next := thisIndex - 1
|
|
94 |
]
|
|
95 |
].
|
|
96 |
(key == #Down) ifTrue:[
|
|
97 |
(thisIndex == (fields size)) ifTrue:[
|
|
98 |
next := 1
|
|
99 |
] ifFalse:[
|
|
100 |
next := thisIndex + 1
|
|
101 |
]
|
|
102 |
].
|
|
103 |
(key == #Return) ifTrue:[
|
|
104 |
(thisIndex == (fields size)) ifTrue:[
|
|
105 |
leaveAction notNil ifTrue:[
|
|
106 |
leaveAction value.
|
|
107 |
currentField := nil
|
|
108 |
] ifFalse:[
|
|
109 |
next := 1
|
|
110 |
]
|
|
111 |
] ifFalse:[
|
|
112 |
next := thisIndex + 1
|
|
113 |
]
|
|
114 |
].
|
|
115 |
next notNil ifTrue:[
|
|
116 |
(fields at:next) enable.
|
|
117 |
currentField := fields at:next
|
|
118 |
]
|
|
119 |
]
|
|
120 |
! !
|
|
121 |
|
|
122 |
!EnterFieldGroup methodsFor:'accessing'!
|
|
123 |
|
|
124 |
leaveAction:aBlock
|
|
125 |
leaveAction := aBlock
|
|
126 |
! !
|
|
127 |
|
|
128 |
!EnterFieldGroup methodsFor:'controlling'!
|
|
129 |
|
7
|
130 |
makeActive:aField
|
|
131 |
currentField notNil ifTrue:[
|
|
132 |
currentField disable
|
|
133 |
].
|
|
134 |
currentField := aField.
|
|
135 |
currentField enable.
|
|
136 |
!
|
|
137 |
|
0
|
138 |
canHandle:aKey
|
|
139 |
^ true
|
|
140 |
!
|
|
141 |
|
7
|
142 |
keyPress:key x:x y:y view:aView
|
0
|
143 |
"key-press in a field"
|
|
144 |
|
|
145 |
currentField notNil ifTrue:[
|
|
146 |
currentField keyPress:key x:0 y:0
|
|
147 |
]
|
|
148 |
!
|
|
149 |
|
7
|
150 |
buttonPress:button x:x y:y view:aView
|
|
151 |
self makeActive:aView.
|
|
152 |
aView buttonPress:button x:x y:y
|
0
|
153 |
!
|
|
154 |
|
7
|
155 |
buttonShiftPress:button x:x y:y view:aView
|
|
156 |
self makeActive:aView.
|
0
|
157 |
aView buttonShiftPress:button x:x y:y
|
|
158 |
!
|
|
159 |
|
7
|
160 |
buttonMultiPress:button x:x y:y view:aView
|
|
161 |
self makeActive:aView.
|
0
|
162 |
aView buttonMultiPress:button x:x y:y
|
|
163 |
!
|
|
164 |
|
7
|
165 |
buttonRelease:button x:x y:y view:aView
|
|
166 |
aView buttonRelease:button x:x y:y
|
0
|
167 |
!
|
|
168 |
|
7
|
169 |
buttonMotion:state x:x y:y view:aView
|
|
170 |
aView buttonMotion:state x:x y:y
|
0
|
171 |
! !
|