avoid accepting twice
authorClaus Gittinger <cg@exept.de>
Tue, 10 Aug 1999 11:21:17 +0200
changeset 1982 66069fc0c683
parent 1981 15a646f9e4fb
child 1983 3261af8573c6
avoid accepting twice
EditField.st
--- a/EditField.st	Wed Aug 04 16:15:06 1999 +0200
+++ b/EditField.st	Tue Aug 10 11:21:17 1999 +0200
@@ -1401,7 +1401,7 @@
                           #DeleteLine #GotoLine #EndOfLine #EndOfText
                           #CursorDown #CursorUp)>
 
-    |leave oldContents newContents|
+    |leave oldContents newContents didAccept|
 
     enabled ifFalse:[
         ^ self
@@ -1438,18 +1438,17 @@
     ].
 
     (key == #Tab) ifTrue:[
+        acceptOnTab ifTrue:[
+            self accept.
+            didAccept := true.
+        ].
+
         tabAction notNil ifTrue:[
             "/ tab-hook. 
-            acceptOnTab ifTrue:[
-                self accept.
-            ].
             tabAction value. 
             ^ self
         ].
 
-        acceptOnTab ifTrue:[
-            self accept.
-        ].
         leave ifFalse:[
             "/ forward it as a Focus-step
             ^ super keyPress:(self sensor shiftDown ifTrue:[#FocusPrevious]
@@ -1459,16 +1458,18 @@
     ].
 
     (key == #Return) ifTrue:[
+        acceptOnReturn ifTrue:[
+            self accept.
+            didAccept := true.
+        ].
         crAction notNil ifTrue:[
             "/ cr-hook. 
-            acceptOnReturn ifTrue:[
-                self accept.
-            ].
             crAction value.
             ^ self
         ].
         leave ifFalse:[
             "/ forward it as a Focus-step
+"/            ^ self windowGroup focusNext.
             ^ super keyPress:#FocusNext x:x y:y
         ]
     ].
@@ -1476,7 +1477,9 @@
     leave ifTrue:[
         ((key == #Return and:[acceptOnReturn])
         or:[key ~~ #Return and:[acceptOnLeave]]) ifTrue:[
-            self accept.
+            didAccept ~~ true ifTrue:[
+                self accept.
+            ]
         ].
 
         leaveAction notNil ifTrue:[
@@ -2042,5 +2045,5 @@
 !EditField class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.139 1999-07-27 16:25:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditField.st,v 1.140 1999-08-10 09:21:17 cg Exp $'
 ! !