initial focus - allow explicit setup via InputFieldSpec
authorClaus Gittinger <cg@exept.de>
Mon, 17 May 2004 17:12:25 +0200
changeset 4178 e176977f5f2c
parent 4177 7c3612e35974
child 4179 d3a1cfe411db
initial focus - allow explicit setup via InputFieldSpec
ModalBox.st
StandardSystemView.st
TopView.st
--- a/ModalBox.st	Thu May 13 21:13:35 2004 +0200
+++ b/ModalBox.st	Mon May 17 17:12:25 2004 +0200
@@ -391,7 +391,7 @@
     and:[(widget := windowGroup defaultKeyboardConsumer) notNil]) ifTrue:[
         windowGroup focusView:widget byTab:false.
     ] ifFalse:[
-        self assignKeyboardFocusToFirstInputField.
+        self assignInitialKeyboardFocus.
     ].
 
     "Modified: / 3.5.1996 / 23:48:04 / stefan"
@@ -919,7 +919,7 @@
 !ModalBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.85 2004-03-09 14:30:03 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ModalBox.st,v 1.86 2004-05-17 15:12:25 cg Exp $'
 ! !
 
 ModalBox initialize!
--- a/StandardSystemView.st	Thu May 13 21:13:35 2004 +0200
+++ b/StandardSystemView.st	Mon May 17 17:12:25 2004 +0200
@@ -918,33 +918,33 @@
     |v|
 
     windowGroup notNil ifTrue:[
-	"/ I got the focus - tell the current focus-windowgroup
-	"/ that its focus is gone elsewhere ...
+        "/ I got the focus - tell the current focus-windowgroup
+        "/ that its focus is gone elsewhere ...
 "/ 'focusIn ' print. windowGroup process name printCR.
 "/ 'focusView is ' print. windowGroup focusView printCR.
 
-	WindowGroup takeFocusFromDevice:device.
+        WindowGroup takeFocusFromDevice:device.
 
-	v := windowGroup focusView.
-	v isNil ifTrue:[
-	    UserPreferences current focusFollowsMouse ~~ false ifTrue:[
-		v := windowGroup pointerView.
+        v := windowGroup focusView.
+        v isNil ifTrue:[
+            UserPreferences current focusFollowsMouse ~~ false ifTrue:[
+                v := windowGroup pointerView.
 "/ 'pointerView is ' print. v printCR.
-		(v notNil 
-		and:[v isKeyboardConsumer not
-		and:[v wantsFocusWithPointerEnter not]]) ifTrue:[
-		    "/ no - not this one
+                (v notNil 
+                and:[v isKeyboardConsumer not
+                and:[v wantsFocusWithPointerEnter not]]) ifTrue:[
+                    "/ no - not this one
 "/ 'not a kbdConsumer' printCR.
-		    v := nil.
-		]
-	    ]
-	].
-	v isNil ifTrue:[
-	    self assignKeyboardFocusToFirstInputField.
-	] ifFalse:[
-	    "/ v requestFocus.  - will be denied; but we must force it here
-	    windowGroup focusView:v byTab:false.
-	]
+                    v := nil.
+                ]
+            ]
+        ].
+        v isNil ifTrue:[
+            self assignInitialKeyboardFocus.
+        ] ifFalse:[
+            "/ v requestFocus.  - will be denied; but we must force it here
+            windowGroup focusView:v byTab:false.
+        ]
     ].
     super focusIn
 
@@ -1535,7 +1535,7 @@
 !StandardSystemView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.157 2004-03-30 20:34:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.158 2004-05-17 15:12:04 cg Exp $'
 ! !
 
 StandardSystemView initialize!
--- a/TopView.st	Thu May 13 21:13:35 2004 +0200
+++ b/TopView.st	Mon May 17 17:12:25 2004 +0200
@@ -472,6 +472,24 @@
 
 !TopView methodsFor:'initialization & release'!
 
+assignInitialKeyboardFocus
+    "assign the initial keyboard focus to a 'useful' component."
+
+    |keyboardProcessor componentWithInitialFocus|
+
+    keyboardProcessor := self keyboardProcessor.
+    keyboardProcessor notNil ifTrue:[
+        componentWithInitialFocus := keyboardProcessor componentWithInitialFocus.
+        componentWithInitialFocus notNil ifTrue:[
+            self windowGroup focusView:componentWithInitialFocus byTab:true.
+            "/ componentWithInitialFocus requestFocus.                    
+            ^ self.
+        ]
+    ].
+
+    self assignKeyboardFocusToFirstInputField.
+!
+
 assignKeyboardFocusToFirstInputField
     "assign the keyboard focus to the first input field,
      or else to the first keyboardConsumer.
@@ -1023,7 +1041,7 @@
 !TopView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.88 2004-04-02 17:33:17 werner Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.89 2004-05-17 15:12:09 cg Exp $'
 ! !
 
 TopView initialize!