diff -r 243d138cf316 -r 7a01cd530452 EnterFieldGroup.st --- a/EnterFieldGroup.st Wed Jan 10 14:54:10 1996 +0100 +++ b/EnterFieldGroup.st Wed Jan 10 15:48:01 1996 +0100 @@ -11,10 +11,10 @@ " Object subclass:#EnterFieldGroup - instanceVariableNames:'fields currentField leaveAction wrap' - classVariableNames:'' - poolDictionaries:'' - category:'Interface-Support' + instanceVariableNames:'fields currentField leaveAction wrap' + classVariableNames:'' + poolDictionaries:'' + category:'Interface-Support' ! !EnterFieldGroup class methodsFor:'documentation'! @@ -306,13 +306,13 @@ " ! ! -!EnterFieldGroup class methodsFor:'instance creation'! +!EnterFieldGroup methodsFor:'accessing'! -new - ^ self basicNew wrap:false -! ! +fields + "return a collection of the inputFields contained in the group." -!EnterFieldGroup methodsFor:'accessing'! + ^ fields +! leaveAction:aBlock "set the action to perform when the last field is left. @@ -323,8 +323,10 @@ ! wrap:aBoolean - "specifies if leaveing the last field via non-Return - should wrap back to the first, or leave the group" + "specifies if leaving the last field via non-Return + should wrap back to the first, or leave the group. + The default is to stay in the input sequence and wrap back to + the first field." wrap := aBoolean ! ! @@ -335,7 +337,7 @@ |thisIndex next action| fields isNil ifTrue:[ - fields := OrderedCollection new + fields := OrderedCollection new ]. fields add:aField. thisIndex := fields size. @@ -352,59 +354,59 @@ "/ currentField disable "/ ]. "/ currentField := aField - self makeActive:aField + self makeActive:aField ]. "set the fields leaveAction to enable next field" aField leaveAction:[:key | "/ Transcript showCr:'left field with: ' , aField editValue. - currentField notNil ifTrue:[ - currentField disable. - currentField hideCursor. - ]. + currentField notNil ifTrue:[ + currentField disable. + currentField hideCursor. + ]. - action := key. - ((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[ - (thisIndex == 1) ifTrue:[ - next := fields size - ] ifFalse:[ - next := thisIndex - 1 - ] - ]. - ((key == #CursorDown) - or:[key == #NextField - or:[key == #Tab]]) ifTrue:[ - (thisIndex == (fields size)) ifTrue:[ - wrap ifFalse:[ - action := #Return. - ] ifTrue:[ - next := 1 - ]. - ] ifFalse:[ - next := thisIndex + 1 - ] - ]. - (action == #Return) ifTrue:[ - (thisIndex == (fields size)) ifTrue:[ - leaveAction notNil ifTrue:[ - leaveAction value. - currentField := nil - ] ifFalse:[ - next := 1 - ] - ] ifFalse:[ - next := thisIndex + 1 - ] - ]. - next notNil ifTrue:[ - self makeActive:(fields at:next) - ] + action := key. + ((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[ + (thisIndex == 1) ifTrue:[ + next := fields size + ] ifFalse:[ + next := thisIndex - 1 + ] + ]. + ((key == #CursorDown) + or:[key == #NextField + or:[key == #Tab]]) ifTrue:[ + (thisIndex == (fields size)) ifTrue:[ + next := 1. + wrap == false ifTrue:[ + action := #Return. + ]. + ] ifFalse:[ + next := thisIndex + 1 + ] + ]. + (action == #Return) ifTrue:[ + (thisIndex == (fields size)) ifTrue:[ + leaveAction notNil ifTrue:[ + currentField := nil. + leaveAction value. + next := nil + ] ifFalse:[ + next := 1 + ] + ] ifFalse:[ + next := thisIndex + 1 + ] + ]. + next notNil ifTrue:[ + self makeActive:(fields at:next) + ] ]. fields size == 1 ifTrue:[ - "the first one" - self makeActive:aField + "the first one" + self makeActive:aField ] ! ! @@ -458,7 +460,7 @@ outside. However, this info is not used by any view currently)" currentField notNil ifTrue:[ - currentField keyPress:key x:-1 y:-1 + currentField keyPress:key x:-1 y:-1 ] ! @@ -501,5 +503,5 @@ !EnterFieldGroup class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.16 1995-12-15 13:04:00 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.17 1996-01-10 14:48:01 ca Exp $' ! !