--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/EnterFieldGroup.st Fri Jul 16 11:44:44 1993 +0200
@@ -0,0 +1,144 @@
+"
+ COPYRIGHT (c) 1992-93 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+Controller subclass:#EnterFieldGroup
+ instanceVariableNames:'fields currentField leaveAction'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Views-Support'
+!
+
+EnterFieldGroup comment:'
+
+COPYRIGHT (c) 1992-93 by Claus Gittinger
+ All Rights Reserved
+
+EnterFieldGroup controlls the interaction between EnterFields
+enabling next/prev field when a field is left. Instances of
+this class keep track of which field of the group is the currentField
+(i.e. the one getting keyboard input).
+The block accessable as leaveAction is evaluated when the last
+field of the group is left (by cursor-down or cr). Usually this block
+triggers some action on the fields.
+
+%W% %E%
+written nov 91 by claus
+'!
+
+!EnterFieldGroup methodsFor:'adding / removing'!
+
+add:aField
+ |thisIndex next|
+
+ fields isNil ifTrue:[
+ fields := OrderedCollection new
+ ].
+ fields add:aField.
+ thisIndex := fields size.
+ aField controller:self.
+ aField disable.
+
+ "set the fields enableAction to disable active field"
+
+ aField enableAction:[
+ currentField notNil ifTrue:[
+ currentField disable
+ ].
+ currentField := aField
+ ].
+
+ "set the fields leaveAction to enable next field"
+
+ aField leaveAction:[:key |
+ currentField notNil ifTrue:[
+ currentField disable
+ ].
+ (key == #Up) ifTrue:[
+ (thisIndex == 1) ifTrue:[
+ next := fields size
+ ] ifFalse:[
+ next := thisIndex - 1
+ ]
+ ].
+ (key == #Down) ifTrue:[
+ (thisIndex == (fields size)) ifTrue:[
+ next := 1
+ ] ifFalse:[
+ next := thisIndex + 1
+ ]
+ ].
+ (key == #Return) ifTrue:[
+ (thisIndex == (fields size)) ifTrue:[
+ leaveAction notNil ifTrue:[
+ leaveAction value.
+ currentField := nil
+ ] ifFalse:[
+ next := 1
+ ]
+ ] ifFalse:[
+ next := thisIndex + 1
+ ]
+ ].
+ next notNil ifTrue:[
+ (fields at:next) enable.
+ currentField := fields at:next
+ ]
+ ]
+! !
+
+!EnterFieldGroup methodsFor:'accessing'!
+
+leaveAction:aBlock
+ leaveAction := aBlock
+! !
+
+!EnterFieldGroup methodsFor:'controlling'!
+
+canHandle:aKey
+ ^ true
+!
+
+keyPress:key x:x y:y in:aView
+ "key-press in a field"
+
+ currentField notNil ifTrue:[
+ currentField keyPress:key x:0 y:0
+ ]
+!
+
+keyPress:key x:x y:y
+ "key-press in an outer view when keyHandler has been set"
+
+ currentField notNil ifTrue:[
+ currentField keyPress:key x:0 y:0
+ ]
+!
+
+buttonMotion:state x:x y:y in:aView
+ aView buttonMotion:state x:x y:y
+!
+
+buttonShiftPress:button x:x y:y in:aView
+ aView buttonShiftPress:button x:x y:y
+!
+
+buttonMultiPress:button x:x y:y in:aView
+ aView buttonMultiPress:button x:x y:y
+!
+
+buttonPress:button x:x y:y in:aView
+ aView buttonPress:button x:x y:y
+!
+
+buttonRelease:button x:x y:y in:aView
+ aView buttonRelease:button x:x y:y
+! !