#BUGFIX by cg
class: UIPainterView
changed: #replaceSelectionBy:
preserve position in child list.
--- a/UIPainterView.st Tue Dec 06 12:52:05 2016 +0100
+++ b/UIPainterView.st Mon Dec 12 23:27:57 2016 +0100
@@ -640,11 +640,12 @@
replaceSelectionBy:aNewSpec
"replace the selected widget by another one."
- |oldSelection treeModel newView oldView container specs|
+ |oldSelection treeModel newView oldView container specs index|
(self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[
^ self
].
+
treeModel := treeView model.
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil.
oldSelection isNil ifTrue:[^ self].
@@ -652,9 +653,10 @@
oldView := oldSelection contents view.
(oldSelection hasChildren and:[aNewSpec class supportsSubComponents]) ifTrue:[
- specs := oldSelection children collect:[:each|
- self fullSpecWithAbsolutePositionFor:(each contents view)
- ].
+ specs :=
+ oldSelection children collect:[:each|
+ self fullSpecWithAbsolutePositionFor:(each contents view)
+ ].
].
aNewSpec
@@ -665,14 +667,15 @@
at:#absOrigin put:(oldView originRelativeTo:self);
yourself).
+ index := oldSelection parent children identityIndexOf:oldSelection.
container := self singleSelection container.
-
+
self withinTransaction:#replaceBy objects:(Array with:oldView) do:[
self withSelectionHiddenDo:[
newView := self
pasteSpecifications:(Array with:aNewSpec)
into:container
- beforeIndex:1
+ beforeIndex:index
keepLayout:true
keepPosition:true
at:#keep.
@@ -684,7 +687,7 @@
into:newView
keepLayout:(aNewSpec class canResizeSubComponents)
keepPosition:(aNewSpec class isLayoutContainer not)
- at:nil.
+ at:index.
].
self select:newView.
].