class: DialogBox
authorClaus Gittinger <cg@exept.de>
Thu, 19 Mar 2015 12:21:21 +0100
changeset 5322 11de8c9ecdde
parent 5321 c557eb17f557
child 5323 5ea789dec86f
class: DialogBox changed: #keyPress:x:y: fixed handling of return key, if current focus is on one of the buttons.
DialogBox.st
--- a/DialogBox.st	Wed Mar 18 19:19:41 2015 +0100
+++ b/DialogBox.st	Thu Mar 19 12:21:21 2015 +0100
@@ -10247,12 +10247,30 @@
 
     <resource: #keyboard (#Return #Escape)>
 
-    |b|
-
-    "/ oops - for old-style DialogBoxes (wo. AppModel), the keyboardProcessor has
-    "/ no one to inform about RETURN/ESCAPE. So the procesing here is still needed.
+    |b focusView|
+
+    "/ notice: the modern way to handle this is via the keyboard processor;
+    "/ however, for old-style DialogBoxes (i.e. without AppModel), the keyboardProcessor has
+    "/ no one to inform about RETURN/ESCAPE. 
+    "/ So the procesing here is still needed.
 
     (aKey == #Return) ifTrue:[
+        focusView := self windowGroup explicitFocusView.
+        "/ in case user tabbed onto one of the buttons, that is the one to trigger
+        focusView notNil ifTrue:[
+            focusView == okButton ifTrue:[
+                ^ self okPressed
+            ].
+            focusView == abortButton ifTrue:[
+                ^ self abortPressed
+            ].
+            (buttonPanel notNil and:[ buttonPanel subViews includesIdentical:focusView ]) ifTrue:[
+                focusView turnOnWithAction.focusView turnOffWithAction.
+                ^ self.
+            ].
+        ].
+
+        "/ the focus is on anything else.
         (okButton notNil and:[okButton isReturnButton]) ifTrue:[
             ^ self okPressed
         ].
@@ -10322,11 +10340,11 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.368 2015-03-18 18:19:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.369 2015-03-19 11:21:21 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.368 2015-03-18 18:19:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.369 2015-03-19 11:21:21 cg Exp $'
 ! !