moved assignKeyboardFocus stuff from topView
to View, to allow for applicationSubviews to do this also
(when adding an application with textViews in it,
as in the fileBrowser, when double clicking in the search list)
--- a/View.st Thu Mar 28 11:32:04 2013 +0100
+++ b/View.st Thu Mar 28 11:32:58 2013 +0100
@@ -198,6 +198,18 @@
"Created: 3.1.1997 / 01:50:36 / stefan"
! !
+!View methodsFor:'accessing-behavior'!
+
+preferFirstInputFieldWhenAssigningInitialFocus
+ "define the focus behavior for dialogs.
+ If true is returned, input fields take precedence over other keyboard consumers.
+ This used to return true, but the behavior is somewhat ugly."
+
+ ^ false
+
+ "Created: / 29-08-2006 / 14:28:54 / cg"
+! !
+
!View methodsFor:'accessing-bg & border'!
allViewBackground:something if:condition
@@ -746,6 +758,41 @@
!View methodsFor:'initialization & release'!
+assignKeyboardFocusToFirstInputField
+ "assign the keyboard focus to the first first keyboardConsumer.
+ (in older versions, this used to favour inputfields over editFields;
+ see (or redefine) preferFirstInputFieldWhenAssigningInitialFocus)"
+
+ |firstInputField firstConsumer firstCursorConsumer consumer|
+
+ self allSubViewsDo:[:v |
+ (firstInputField isNil and:[v isInputField]) ifTrue:[
+ firstInputField := v
+ ].
+ (firstConsumer isNil and:[v isKeyboardConsumer]) ifTrue:[
+ firstConsumer := v
+ ].
+ (firstCursorConsumer isNil and:[v isCursorKeyConsumer]) ifTrue:[
+ firstCursorConsumer := v
+ ].
+ ].
+ self preferFirstInputFieldWhenAssigningInitialFocus ifTrue:[
+ consumer := firstInputField.
+ ].
+ consumer := (consumer ? firstConsumer ? firstCursorConsumer).
+ consumer notNil ifTrue:[
+ device platformName = 'WIN32' ifTrue:[
+ self windowGroup focusView:consumer byTab:true.
+ ] ifFalse:[
+ consumer requestFocus.
+ "/ consumer requestFocus. - could be denied; but we force it here
+ windowGroup focusView:consumer byTab:false.
+ ].
+ ].
+
+ "Modified: / 29-08-2006 / 14:32:30 / cg"
+!
+
initialize
super initialize.
@@ -789,5 +836,6 @@
!View class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/View.st,v 1.80 2008-06-28 11:55:50 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/View.st,v 1.81 2013-03-28 10:32:58 cg Exp $'
! !
+