changed #canMoveSelectionIntoContainer
authorStefan Vogel <sv@exept.de>
Mon, 25 Feb 2008 15:11:34 +0100
changeset 2280 d9a56ee79c70
parent 2279 f077161d5d57
child 2281 e6cc565bff35
changed #canMoveSelectionIntoContainer -- Allow to move a widget into the next container in the list (same level)
UIPainter.st
--- a/UIPainter.st	Mon Feb 25 15:10:16 2008 +0100
+++ b/UIPainter.st	Mon Feb 25 15:11:34 2008 +0100
@@ -2455,9 +2455,8 @@
 !
 
 canMoveSelectionIntoContainer
-    "returns a boolean value holder which is true in case that one widget is selected
-     and can change its container widget to the next element in the list which will have
-     the same container"
+    "returns true in case that one widget is selected and can change its container
+     widget to an element below"
 
     ^ builder booleanValueAspectFor:#canMoveSelectionIntoContainer
 !
@@ -5584,18 +5583,20 @@
 
 canMoveSelectionIntoContainer
     "returns true in case that one widget is selected and can change its container
-     widget to the next element in the list which will have the same container"
-
-    |item prnt container|
-
-    (     (item := self selectedNode) isNil
-      or:[(prnt := item parent) isNil
-      or:[(container := prnt childAt:((prnt indexOfChild:item) + 1)) isNil
-      or:[container contents spec class supportsSubComponents not]]]
-    ) ifTrue:[
-        ^ false
+     widget to an element below"
+
+    |item oldParentItem newParentItem idx|
+
+    item := self selectedNode.
+    (item notNil and:[(oldParentItem := item parent) notNil]) ifTrue:[
+        idx := (oldParentItem indexOfChild:item) + 1.
+        newParentItem := oldParentItem children detect:[:eachChild|
+            eachChild contents spec class supportsSubComponents
+        ] startingAt:idx ifNone:nil.
+        ^ newParentItem notNil.
     ].
-    ^ true
+
+    ^ false
 !
 
 canMoveSelectionOutOfContainer
@@ -5683,14 +5684,19 @@
 !
 
 doStepIn
-    |item prnt|
-
-    (     (item := self selectedNode) isNil
-      or:[(prnt := item parent) isNil
-      or:[(prnt := prnt childAt:((prnt indexOfChild:item) + 1)) isNil
-      or:[prnt contents spec class supportsSubComponents not]]]
-    ) ifFalse:[
-        self doChangeHierarchyOf:prnt
+    "move the currently selected widget into the next available container below"
+
+    |item oldParentItem newParentItem idx|
+
+    item := self selectedNode.
+    (item notNil and:[(oldParentItem := item parent) notNil]) ifTrue:[
+        idx := (oldParentItem indexOfChild:item) + 1.
+        newParentItem := oldParentItem children detect:[:eachChild|
+            eachChild contents spec class supportsSubComponents
+        ] startingAt:idx ifNone:nil.
+        newParentItem notNil ifTrue:[
+            self doChangeHierarchyOf:newParentItem
+        ].
     ]
 !