fixed Tab handling in enterFieldGroups;
authorClaus Gittinger <cg@exept.de>
Wed, 31 Jan 1996 02:10:17 +0100
changeset 316 1e27aa926710
parent 315 dbfd0ae75b57
child 317 f23de8b78f5e
fixed Tab handling in enterFieldGroups; cleanup in enterField (enableAction renamed to clickAction)
EFGroup.st
EditField.st
EnterFieldGroup.st
--- a/EFGroup.st	Tue Jan 30 12:31:57 1996 +0100
+++ b/EFGroup.st	Wed Jan 31 02:10:17 1996 +0100
@@ -334,10 +334,10 @@
 !EnterFieldGroup methodsFor:'adding / removing'!
 
 add:aField
-    |thisIndex next action|
+    |thisIndex action|
 
     fields isNil ifTrue:[
-        fields := OrderedCollection new
+	fields := OrderedCollection new
     ].
     fields add:aField.
     thisIndex := fields size.
@@ -348,65 +348,75 @@
 
     "set the fields enableAction to disable active field"
 
-    aField enableAction:[
-"/ Transcript showCr:'enable field with: ' , aField editValue.
-"/        currentField notNil ifTrue:[
-"/            currentField disable
-"/        ].
-"/        currentField := aField
-        self makeActive:aField
+    aField clickAction:[:field |
+	self makeActive:field
     ].
 
     "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.
-        ].
+	|next wg explicit nFields nextField|
+
+"/        currentField notNil ifTrue:[
+"/            currentField disable.
+"/            currentField hideCursor.
+"/        ].
+"/
+	action := key.
+	nFields := fields size.
 
-        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) 
-        ]
+	((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[
+	    (thisIndex == 1) ifTrue:[
+		next := nFields
+	    ] ifFalse:[
+		next := thisIndex - 1
+	    ]
+	].
+	((key == #CursorDown) 
+	or:[key == #NextField
+	or:[key == #Tab]]) ifTrue:[
+	    (thisIndex == nFields) ifTrue:[
+		next := 1.
+		wrap == false ifTrue:[
+		    action := #Return.
+		].
+	    ] ifFalse:[
+		next := thisIndex + 1
+	    ]
+	].
+	(action == #Return) ifTrue:[
+	    (thisIndex == nFields) ifTrue:[
+		leaveAction notNil ifTrue:[
+		    currentField := nil.
+		    leaveAction value.
+		    next := nil
+		] ifFalse:[
+		    next := 1
+		]
+	    ] ifFalse:[
+		next := thisIndex + 1
+	    ]
+	].
+	next notNil ifTrue:[
+	    nextField := fields at:next.
+
+	    explicit := false.
+	    (wg := currentField windowGroup) notNil ifTrue:[
+		wg focusView == currentField ifTrue:[
+		    explicit := true.
+		]
+	    ].
+	    explicit ifTrue:[
+		wg focusView:nextField.
+	    ] ifFalse:[
+		self makeActive:nextField 
+	    ]
+	]
     ].
 
     fields size == 1 ifTrue:[
-        "the first one"
-        self makeActive:aField
+	"the first one"
+	self makeActive:aField
     ]
 ! !
 
@@ -460,7 +470,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
     ]
 !
 
@@ -489,6 +499,8 @@
 makeActive:aField
     "make a specific field the active one"
 
+    currentField == aField ifTrue:[^ self].
+
     currentField notNil ifTrue:[
 	currentField disable.
 	currentField hideCursor.
@@ -503,5 +515,5 @@
 !EnterFieldGroup class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/EFGroup.st,v 1.17 1996-01-10 14:48:01 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/EFGroup.st,v 1.18 1996-01-31 01:10:10 cg Exp $'
 ! !
--- a/EditField.st	Tue Jan 30 12:31:57 1996 +0100
+++ b/EditField.st	Wed Jan 31 02:10:17 1996 +0100
@@ -11,7 +11,7 @@
 "
 
 EditTextView subclass:#EditField
-	instanceVariableNames:'leaveAction enabled enableAction crAction tabAction converter
+	instanceVariableNames:'leaveAction enabled clickAction crAction tabAction converter
 		leaveKeys immediateAccept acceptOnLeave acceptOnReturn
 		lengthLimit entryCompletionBlock passwordCharacter
 		cursorMovementWhenUpdating enableChannel autoScrollHorizontally
@@ -105,8 +105,8 @@
 
       enabled        <Boolean>                  if false, input is ignored.
 
-      enableAction   <Block | nil>              action performed if the field is
-						enabled via an explicit click.
+      clickAction    <Block | nil>              action performed if the field is
+						clicked upon.
 						(this is used by the group to
 						 set the active field to the clicked upon field)
 
@@ -831,10 +831,10 @@
     "Modified: 16.12.1995 / 16:28:09 / cg"
 !
 
-enableAction:aBlock
-    "define an action to be evaluated when enabled by clicking upon"
+clickAction:aBlock
+    "define an action to be evaluated when being clicked upon"
 
-    enableAction := aBlock
+    clickAction := aBlock
 !
 
 entryCompletionBlock:aOneArgBlock
@@ -1159,15 +1159,20 @@
 buttonPress:button x:x y:y
     "enable myself on mouse click"
 
-    enabled ifFalse:[
-	enabled := true.
-	super buttonPress:button x:x y:y.
-	enableAction notNil ifTrue:[
-	    enableAction value
-	]
-    ] ifTrue:[
-	super buttonPress:button x:x y:y
-    ]
+    clickAction notNil ifTrue:[
+	clickAction value:self
+    ].
+    super buttonPress:button x:x y:y
+
+"/    enabled ifFalse:[
+"/        enabled := true.
+"/        super buttonPress:button x:x y:y.
+"/        enableAction notNil ifTrue:[
+"/            enableAction value
+"/        ]
+"/    ] ifTrue:[
+"/        super buttonPress:button x:x y:y
+"/    ]
 !
 
 canHandle:aKey
@@ -1195,15 +1200,16 @@
 focusIn
     "got the explicit focus"
 
-    enabled ifFalse:[
-	enabled := true.
-	super focusIn.
-	enableAction notNil ifTrue:[
-	    enableAction value
-	]
-    ] ifTrue:[
-	super focusIn
-    ].
+"/    enabled ifFalse:[
+"/        enabled := true.
+"/        super focusIn.
+"/        enableAction notNil ifTrue:[
+"/            enableAction value
+"/        ]
+"/    ] ifTrue:[
+"/        super focusIn
+"/    ].
+    ^ super focusIn
 !
 
 keyPress:key x:x y:y
@@ -1333,6 +1339,15 @@
 	    self scrollHorizontalTo:newOffset.
 	]
     ].
+!
+
+showFocus:explicit
+    "/ giving me the focus is loke clicking on me
+    "/ (tell my enterFieldGroup ....
+
+    clickAction notNil ifTrue:[clickAction value:self].
+    self showCursor.
+    super showFocus:explicit
 ! !
 
 !EditField methodsFor:'initialization'!
@@ -1551,5 +1566,5 @@
 !EditField class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.41 1996-01-27 15:37:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.42 1996-01-31 01:10:17 cg Exp $'
 ! !
--- a/EnterFieldGroup.st	Tue Jan 30 12:31:57 1996 +0100
+++ b/EnterFieldGroup.st	Wed Jan 31 02:10:17 1996 +0100
@@ -334,10 +334,10 @@
 !EnterFieldGroup methodsFor:'adding / removing'!
 
 add:aField
-    |thisIndex next action|
+    |thisIndex action|
 
     fields isNil ifTrue:[
-        fields := OrderedCollection new
+	fields := OrderedCollection new
     ].
     fields add:aField.
     thisIndex := fields size.
@@ -348,65 +348,75 @@
 
     "set the fields enableAction to disable active field"
 
-    aField enableAction:[
-"/ Transcript showCr:'enable field with: ' , aField editValue.
-"/        currentField notNil ifTrue:[
-"/            currentField disable
-"/        ].
-"/        currentField := aField
-        self makeActive:aField
+    aField clickAction:[:field |
+	self makeActive:field
     ].
 
     "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.
-        ].
+	|next wg explicit nFields nextField|
+
+"/        currentField notNil ifTrue:[
+"/            currentField disable.
+"/            currentField hideCursor.
+"/        ].
+"/
+	action := key.
+	nFields := fields size.
 
-        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) 
-        ]
+	((key == #CursorUp) or:[key == #PreviousField]) ifTrue:[
+	    (thisIndex == 1) ifTrue:[
+		next := nFields
+	    ] ifFalse:[
+		next := thisIndex - 1
+	    ]
+	].
+	((key == #CursorDown) 
+	or:[key == #NextField
+	or:[key == #Tab]]) ifTrue:[
+	    (thisIndex == nFields) ifTrue:[
+		next := 1.
+		wrap == false ifTrue:[
+		    action := #Return.
+		].
+	    ] ifFalse:[
+		next := thisIndex + 1
+	    ]
+	].
+	(action == #Return) ifTrue:[
+	    (thisIndex == nFields) ifTrue:[
+		leaveAction notNil ifTrue:[
+		    currentField := nil.
+		    leaveAction value.
+		    next := nil
+		] ifFalse:[
+		    next := 1
+		]
+	    ] ifFalse:[
+		next := thisIndex + 1
+	    ]
+	].
+	next notNil ifTrue:[
+	    nextField := fields at:next.
+
+	    explicit := false.
+	    (wg := currentField windowGroup) notNil ifTrue:[
+		wg focusView == currentField ifTrue:[
+		    explicit := true.
+		]
+	    ].
+	    explicit ifTrue:[
+		wg focusView:nextField.
+	    ] ifFalse:[
+		self makeActive:nextField 
+	    ]
+	]
     ].
 
     fields size == 1 ifTrue:[
-        "the first one"
-        self makeActive:aField
+	"the first one"
+	self makeActive:aField
     ]
 ! !
 
@@ -460,7 +470,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
     ]
 !
 
@@ -489,6 +499,8 @@
 makeActive:aField
     "make a specific field the active one"
 
+    currentField == aField ifTrue:[^ self].
+
     currentField notNil ifTrue:[
 	currentField disable.
 	currentField hideCursor.
@@ -503,5 +515,5 @@
 !EnterFieldGroup class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.17 1996-01-10 14:48:01 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EnterFieldGroup.st,v 1.18 1996-01-31 01:10:10 cg Exp $'
 ! !