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:'
|
|
21 |
|
5
|
22 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
0
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
EnterFieldGroup controlls the interaction between EnterFields
|
|
26 |
enabling next/prev field when a field is left. Instances of
|
|
27 |
this class keep track of which field of the group is the currentField
|
|
28 |
(i.e. the one getting keyboard input).
|
|
29 |
The block accessable as leaveAction is evaluated when the last
|
|
30 |
field of the group is left (by cursor-down or cr). Usually this block
|
|
31 |
triggers some action on the fields.
|
|
32 |
|
7
|
33 |
$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.4 1993-12-11 01:42:31 claus Exp $
|
0
|
34 |
written nov 91 by claus
|
|
35 |
'!
|
|
36 |
|
|
37 |
!EnterFieldGroup methodsFor:'adding / removing'!
|
|
38 |
|
|
39 |
add:aField
|
|
40 |
|thisIndex next|
|
|
41 |
|
|
42 |
fields isNil ifTrue:[
|
|
43 |
fields := OrderedCollection new
|
|
44 |
].
|
|
45 |
fields add:aField.
|
|
46 |
thisIndex := fields size.
|
7
|
47 |
aField delegate:self.
|
0
|
48 |
aField disable.
|
|
49 |
|
|
50 |
"set the fields enableAction to disable active field"
|
|
51 |
|
|
52 |
aField enableAction:[
|
|
53 |
currentField notNil ifTrue:[
|
|
54 |
currentField disable
|
|
55 |
].
|
|
56 |
currentField := aField
|
|
57 |
].
|
|
58 |
|
|
59 |
"set the fields leaveAction to enable next field"
|
|
60 |
|
|
61 |
aField leaveAction:[:key |
|
|
62 |
currentField notNil ifTrue:[
|
|
63 |
currentField disable
|
|
64 |
].
|
|
65 |
(key == #Up) ifTrue:[
|
|
66 |
(thisIndex == 1) ifTrue:[
|
|
67 |
next := fields size
|
|
68 |
] ifFalse:[
|
|
69 |
next := thisIndex - 1
|
|
70 |
]
|
|
71 |
].
|
|
72 |
(key == #Down) ifTrue:[
|
|
73 |
(thisIndex == (fields size)) ifTrue:[
|
|
74 |
next := 1
|
|
75 |
] ifFalse:[
|
|
76 |
next := thisIndex + 1
|
|
77 |
]
|
|
78 |
].
|
|
79 |
(key == #Return) ifTrue:[
|
|
80 |
(thisIndex == (fields size)) ifTrue:[
|
|
81 |
leaveAction notNil ifTrue:[
|
|
82 |
leaveAction value.
|
|
83 |
currentField := nil
|
|
84 |
] ifFalse:[
|
|
85 |
next := 1
|
|
86 |
]
|
|
87 |
] ifFalse:[
|
|
88 |
next := thisIndex + 1
|
|
89 |
]
|
|
90 |
].
|
|
91 |
next notNil ifTrue:[
|
|
92 |
(fields at:next) enable.
|
|
93 |
currentField := fields at:next
|
|
94 |
]
|
|
95 |
]
|
|
96 |
! !
|
|
97 |
|
|
98 |
!EnterFieldGroup methodsFor:'accessing'!
|
|
99 |
|
|
100 |
leaveAction:aBlock
|
|
101 |
leaveAction := aBlock
|
|
102 |
! !
|
|
103 |
|
|
104 |
!EnterFieldGroup methodsFor:'controlling'!
|
|
105 |
|
7
|
106 |
makeActive:aField
|
|
107 |
currentField notNil ifTrue:[
|
|
108 |
currentField disable
|
|
109 |
].
|
|
110 |
currentField := aField.
|
|
111 |
currentField enable.
|
|
112 |
!
|
|
113 |
|
0
|
114 |
canHandle:aKey
|
|
115 |
^ true
|
|
116 |
!
|
|
117 |
|
7
|
118 |
keyPress:key x:x y:y view:aView
|
0
|
119 |
"key-press in a field"
|
|
120 |
|
|
121 |
currentField notNil ifTrue:[
|
|
122 |
currentField keyPress:key x:0 y:0
|
|
123 |
]
|
|
124 |
!
|
|
125 |
|
7
|
126 |
buttonPress:button x:x y:y view:aView
|
|
127 |
self makeActive:aView.
|
|
128 |
aView buttonPress:button x:x y:y
|
0
|
129 |
!
|
|
130 |
|
7
|
131 |
buttonShiftPress:button x:x y:y view:aView
|
|
132 |
self makeActive:aView.
|
0
|
133 |
aView buttonShiftPress:button x:x y:y
|
|
134 |
!
|
|
135 |
|
7
|
136 |
buttonMultiPress:button x:x y:y view:aView
|
|
137 |
self makeActive:aView.
|
0
|
138 |
aView buttonMultiPress:button x:x y:y
|
|
139 |
!
|
|
140 |
|
7
|
141 |
buttonRelease:button x:x y:y view:aView
|
|
142 |
aView buttonRelease:button x:x y:y
|
0
|
143 |
!
|
|
144 |
|
7
|
145 |
buttonMotion:state x:x y:y view:aView
|
|
146 |
aView buttonMotion:state x:x y:y
|
0
|
147 |
! !
|