# HG changeset patch # User Claus Gittinger # Date 1197889523 -3600 # Node ID 8ac60d4545ad69ba3a18e47922651d3c67b1f32d # Parent ff2b5cb004c21139796a0abe1e9742421d87fe90 selection after paste diff -r ff2b5cb004c2 -r 8ac60d4545ad UIPainterView.st --- a/UIPainterView.st Mon Dec 17 12:04:57 2007 +0100 +++ b/UIPainterView.st Mon Dec 17 12:05:23 2007 +0100 @@ -215,6 +215,12 @@ !UIPainterView methodsFor:'copy & cut & paste'! +changeSelectionAfterPasteOf:sel + sel notNil ifTrue:[ + self select:sel. + ]. +! + commonContainerOf:someComponents |container| @@ -329,10 +335,7 @@ |sel| sel := self pasteSpecifications:(self getClipboardObject) keepLayout:false. - - sel notNil ifTrue:[ - self select:sel. - ]. + self changeSelectionAfterPasteOf:sel. ! pasteKeepingPosition @@ -348,9 +351,7 @@ keepPosition:true at:nil. - sel notNil ifTrue:[ - self select:sel. - ]. + self changeSelectionAfterPasteOf:sel. ! pasteSpecifications:aSpecificationOrList keepLayout:keepLayout @@ -388,7 +389,7 @@ ] ifFalse:[ containerToPasteInto := self ]. - self selection:containerToPasteInto. +"/ self selection:containerToPasteInto. ]. (self canPasteInto:containerToPasteInto) ifFalse:[ @@ -401,14 +402,16 @@ containerToPasteInto := containerToPasteInto container. ]. ]. - self selection:containerToPasteInto. +"/ self selection:containerToPasteInto. ]. ]. containerToPasteInto isNil ifTrue:[ containerToPasteInto := self ]. - (self canPaste:aSpecificationOrList) ifFalse:[ + (self canPaste:aSpecificationOrList into:containerToPasteInto) + "(self canPaste:aSpecificationOrList)" + ifFalse:[ Dialog warn:'Cannot paste into selected component (not a container ?)'. ^ nil ]. @@ -418,7 +421,7 @@ ] ifFalse:[ paste := Array with:aSpecificationOrList ]. - self setClipboardObject:nil. +"/ self setClipboardObject:nil. newSel := OrderedCollection new. builder := UIBuilder new isEditing:true. @@ -495,10 +498,7 @@ |sel| sel := self pasteSpecifications:(self getClipboardObject) keepLayout:true. - - sel notNil ifTrue:[ - self select:sel. - ]. + self changeSelectionAfterPasteOf:sel. ! ! !UIPainterView methodsFor:'drag & drop'! @@ -529,6 +529,12 @@ canPaste:something "returns true if something could be pasted" + ^ self canPaste:something into:(self singleSelection) +! + +canPaste:something into:containerToPasteInto + "returns true if something could be pasted" + |el size| ((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ @@ -543,7 +549,7 @@ ]. size == 1 ifTrue:[ - ^ self canPasteInto:(self singleSelection) + ^ self canPasteInto:containerToPasteInto ]. ^ true !