change drop mechanism:
if selected widget is not a container, drop the element
at the current pointer position.
--- a/UIPainterView.st Wed Aug 20 17:57:49 1997 +0200
+++ b/UIPainterView.st Wed Aug 20 18:06:03 1997 +0200
@@ -305,9 +305,11 @@
!UIPainterView methodsFor:'drag & drop'!
-canDrop:anObjectOrCollection
- anObjectOrCollection size == 1 ifTrue:[
- ^ self canPaste:(anObjectOrCollection first theObject)
+canDrop:something
+ "returns true if something can be droped
+ "
+ (something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[
+ ^ something first theObject isKindOf:UISpecification
].
^ false
!
@@ -359,8 +361,13 @@
drop:anObjectOrCollection at:aPoint
|spec newSel oldSel dragOffset|
- (oldSel := selection) isCollection ifTrue:[
- oldSel := selection copy
+ self selection notNil ifTrue:[
+ oldSel := self singleSelection.
+
+ (self canPasteInto:oldSel) ifFalse:[
+ oldSel := nil.
+ self setSelection:nil withRedraw:true
+ ]
].
spec := (anObjectOrCollection at:1) theObject.
dragOffset := DragAndDropManager dragOffsetQuerySignal raise.
@@ -368,30 +375,56 @@
oldSel isNil ifTrue:[self select:newSel]
ifFalse:[self select:oldSel]
-
- "Modified: 11.8.1997 / 16:41:52 / cg"
! !
!UIPainterView methodsFor:'generating output'!
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass
- |args showIt|
+ |selector args showIt code alreadyInSuperclass|
+
+ selector := aspect asSymbol.
- (aspect asSymbol numArgs) == 1 ifFalse:[
- args := '\'.
+ alreadyInSuperclass := targetClass superclass canUnderstand:selector.
+
+ (selector numArgs) == 1 ifFalse:[
+ args := ''.
showIt := ' ...''.\'.
] ifTrue:[
- args := 'anArgument\'.
+ args := 'anArgument'.
showIt := ''' , anArgument printString , '' ...''.\'.
].
- ^ ('!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
- aspect , args ,
- ' "automatically generated by UIPainter ..."\' ,
- '\' ,
- ' "action to be added ..."\' ,
- ' Transcript showCR:self class name , '': action for ' , aspect , showIt ,
- '!! !!\\') withCRs
+ code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' ,
+ aspect , args , '\' ,
+ ' "automatically generated by UIPainter ..."\' ,
+ '\' .
+
+ alreadyInSuperclass ifTrue:[
+ code := code ,
+ ' "action for ' , aspect , ' is already provided in a superclass."\' ,
+ ' "It may be redefined here ..."\\'.
+ ] ifFalse:[
+ code := code ,
+ ' "action to be added ..."\\'.
+ ].
+
+ code := code ,
+ ' Transcript showCR:self class name, '': '.
+ alreadyInSuperclass ifTrue:[
+ code := code , 'inherited '.
+ ].
+ code := code , 'action for ' , aspect , showIt.
+
+ alreadyInSuperclass ifTrue:[
+ code := code ,
+ ' super ' , aspect , args , '.\'.
+ ].
+
+ code := code ,
+ '!! !!\\'.
+ ^ code withCRs
+
+ "Modified: 19.8.1997 / 12:03:20 / cg"
!
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass