focus handling changed: looking for subviewsInFocusOrder
authorca
Fri, 02 Mar 2007 16:02:38 +0100
changeset 4734 cad9cacb9cde
parent 4733 80b915a584ab
child 4735 b57247f61e6a
focus handling changed: looking for subviewsInFocusOrder
SimpleView.st
--- a/SimpleView.st	Fri Mar 02 16:01:47 2007 +0100
+++ b/SimpleView.st	Fri Mar 02 16:02:38 2007 +0100
@@ -5943,22 +5943,50 @@
 
 focusNext
     "get next focus view to self
-     Skip invisible & disabled widgets."
+     Skip invisible, disabled or widgets the extent is to small"
 
     |viewInSubView|
 
-    (shown and:[subViews notNil]) ifTrue:[
-	subViews do:[:aSubView|
-	    aSubView shown ifTrue:[
-		(aSubView canTab and:[aSubView enabled]) ifTrue:[
-		    ^ aSubView
-		].
-
-		(viewInSubView := aSubView focusNext) notNil ifTrue:[
-		    ^ viewInSubView
-		]
-	    ]
-	]
+    shown ifTrue:[
+        self subviewsInFocusOrder do:[:aSubView|
+            aSubView shown ifTrue:[
+                (aSubView canTab and:[aSubView enabled]) ifTrue:[
+                    ^ aSubView
+                ].
+
+                (viewInSubView := aSubView focusNext) notNil ifTrue:[
+                    ^ viewInSubView
+                ].
+            ]
+        ].
+    ].
+    ^ nil
+!
+
+focusNextChildAfter:aChildView
+    "get the next focus view after aChildView in mySelf or nil,
+     if there is none.
+     Skip invisible or disabled widgets"
+
+    |viewInSubView index subviewsInFocusOrder|
+
+    shown ifFalse:[ ^ nil ].
+    subViews isNil ifTrue:[ ^ nil ].
+    subviewsInFocusOrder := self subviewsInFocusOrder.
+
+    index := subviewsInFocusOrder identityIndexOf:aChildView.
+    index == 0 ifTrue:[ ^ nil ].
+
+    subviewsInFocusOrder from:(index + 1) do:[:eachChildAfterTheOne |
+        eachChildAfterTheOne shown ifTrue:[
+            (eachChildAfterTheOne canTab and:[eachChildAfterTheOne enabled]) ifTrue:[
+                ^ eachChildAfterTheOne
+            ].
+
+            (viewInSubView := eachChildAfterTheOne focusNext) notNil ifTrue:[
+                ^ viewInSubView
+            ].
+        ].
     ].
     ^ nil
 !
@@ -5969,20 +5997,52 @@
 
     |viewInSubView|
 
-    (shown and:[subViews notNil]) ifTrue:[
-	subViews reverseDo:[:aSubView|
-	    aSubView shown ifTrue:[
-		viewInSubView := aSubView focusPrevious.
-
-		viewInSubView notNil ifTrue:[
-		    ^ viewInSubView
-		].
-		(aSubView canTab and:[aSubView enabled]) ifTrue:[
-		    ^ aSubView
-		].
-	    ]
-	]
-    ].
+    shown ifTrue:[
+        self subviewsInFocusOrder reverseDo:[:aSubView|
+            aSubView shown ifTrue:[
+                viewInSubView := aSubView focusPrevious.
+
+                viewInSubView notNil ifTrue:[
+                    ^ viewInSubView
+                ].
+                (aSubView canTab and:[aSubView enabled]) ifTrue:[
+                    ^ aSubView
+                ].
+            ]
+        ]
+    ].
+    ^ nil
+!
+
+focusPreviousChildBefore:aChildView
+    "get the previous focus view before aChildView in mySelf or nil, if there is none.
+     Skip invisible or disabled widgets"
+
+    |viewInSubView index subviewsInFocusOrder|
+
+    shown ifFalse:[ ^ nil ].
+    subViews isNil ifTrue:[ ^ nil ].
+    subviewsInFocusOrder := self subviewsInFocusOrder.
+
+    index := subviewsInFocusOrder identityIndexOf:aChildView.
+    index == 0 ifTrue:[ ^ nil ].
+
+    subviewsInFocusOrder from:1 to:(index - 1) reverseDo:[:eachChildBeforeTheOne |
+        eachChildBeforeTheOne shown ifTrue:[
+            (viewInSubView := eachChildBeforeTheOne focusPrevious) notNil ifTrue:[
+                ^ viewInSubView
+            ].
+
+            (eachChildBeforeTheOne canTab and:[eachChildBeforeTheOne enabled]) ifTrue:[
+                ^ eachChildBeforeTheOne
+            ].
+        ].
+    ].
+    "/ the code below allows for a notebooks tab-list to be reached
+    (self canTab and:[self enabled]) ifTrue:[
+        ^ self
+    ].
+
     ^ nil
 !
 
@@ -6111,6 +6171,10 @@
     "Modified: / 17.9.1998 / 15:08:02 / cg"
 !
 
+subviewsInFocusOrder
+    ^ subViews ? #()
+!
+
 takeFocus
     "Unconditionally take the focus from my windowGroup"
 
@@ -7504,14 +7568,6 @@
     ].
 !
 
-focusSequence
-    "return nil - for compatibility with StdSysView & SubCanvas.
-     In the future, subviews which want to slice their components into the
-     focusSequence may redefine this to return a list of their components."
-
-    ^ nil
-!
-
 hasFocus
     "return true, if the receiver has the keyboard focus
      (either via the focusView mechanism in the windowGroup,
@@ -9906,7 +9962,7 @@
 !SimpleView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.562 2007-02-21 15:04:13 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.563 2007-03-02 15:02:38 ca Exp $'
 ! !
 
 SimpleView initialize!