diff -r 9f9cf71a311c -r 042e31fded4f UIPainterView.st --- a/UIPainterView.st Fri Aug 08 14:08:05 2008 +0200 +++ b/UIPainterView.st Fri Aug 08 16:43:31 2008 +0200 @@ -272,53 +272,55 @@ self deleteSelectionBuffered: true ! -deleteSelectionBuffered: buffered +deleteSelectionBuffered:buffered "cut the selection. If buffered is true, place it into the cut&paste-buffer" - |specs specsToRemove index oldSelection newSelection treeModel children size node| + |specs viewsToRemove newSelection firstView| treeView askForSelectionChangeAllowed ifFalse:[^ self]. - specsToRemove := self minClosedViewSetFor:(self selection). - specsToRemove notEmptyOrNil ifTrue:[ + viewsToRemove := self minClosedViewSetFor:(self selection). + viewsToRemove isEmptyOrNil ifTrue:[ ^ self]. + + buffered ifTrue:[ + specs := viewsToRemove collect:[:aView| self fullSpecWithAbsolutePositionFor:aView ]. + self setClipboardObject:specs + ]. + firstView := viewsToRemove first. + newSelection := self findContainerOfView:firstView. + + newSelection isNil ifTrue:[ + newSelection := self. + ] ifFalse:[ + viewsToRemove size == 1 ifTrue:[ + |subviews index| + + subviews := newSelection subViews. + + subviews size > 1 ifTrue:[ + index := subviews findFirst:[:eachView| eachView isSameOrComponentOf:firstView ]. + index > 0 ifTrue:[ + newSelection := subviews + at:(index + 1) + ifAbsent:[subviews at:index -1]. + ]. + ]. + ]. + ]. + + self withSelectionHiddenDo:[ + self select:newSelection. + treeView canvasEventsDisabledDo:[ - treeModel := treeView model. - oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. - - oldSelection notNil ifTrue:[ - children := oldSelection parent children. - (size := children size) > 1 ifTrue:[ - index := children identityIndexOf:oldSelection. - size == index ifTrue:[ - index := index - 1 - ]. - newSelection := children at:index ifAbsent:1. - ] ifFalse:[ - newSelection := oldSelection parent - ]. - newSelection := treeModel indexOf:newSelection. - ] ifFalse:[ - newSelection := 1 - ]. - - self hideSelection. - selection := nil. - specs := specsToRemove collect:[:aView| self fullSpecWithAbsolutePositionFor:aView ]. - - self withinTransaction:#cut objects:specsToRemove do:[ - specsToRemove reverseDo:[:aView| + self withinTransaction:#cut objects:viewsToRemove do:[ + viewsToRemove reverseDo:[:aView| self createUndoRemove:aView. self remove:aView. ] ]. - buffered ifTrue: [self setClipboardObject:specs]. - treeView selection:nil. - treeView selection:(Array with: newSelection). - (node := treeView selectedNode) notNil ifTrue:[ - self setSelection:node contents view withRedraw:true. - ] - ] - ] + ]. + self windowGroup processRealExposeEvents. + ]. ! deleteTotalSelection