DragAndDropManager.st
changeset 513 8334721d93bb
parent 411 8b8b0128d129
child 515 7df33af3beaa
--- a/DragAndDropManager.st	Fri Apr 04 22:46:41 1997 +0200
+++ b/DragAndDropManager.st	Sat Apr 05 01:59:02 1997 +0200
@@ -14,14 +14,14 @@
 	privateIn:DragAndDropManager
 !
 
-View subclass:#DemoView2
+View subclass:#DemoView3
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:DragAndDropManager
 !
 
-View subclass:#DemoView3
+View subclass:#DemoView2
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
@@ -498,22 +498,30 @@
 
 drop:something in:targetView at:aPoint from:sourceView ifOk:okAction ifFail:failAction
     "try to drop some object in a targetView;
-     if the targetView takes it, okAction is evaluated ;
-     if not, failAction is evaluated"
+     if any view along the targetViews superView chain takes it, 
+     the okAction is evaluated; if not, failAction is evaluated."
+
+    |v pnt|
+
+    v := targetView.
+    pnt := aPoint.
 
-    (targetView canDrop:something) ifFalse:[
-        failAction value.
-        ^ false
+    [v notNil] whileTrue:[
+        (v canDrop:something) ifTrue:[
+            v 
+                drop:something 
+                at:aPoint 
+                from:sourceView 
+                with:[:o | okAction. ^ true]
+                ifFail:[:o | failAction. ^ false].
+        ].
+        v := v superView.
+        pnt := nil
     ].
-    targetView drop:something at:aPoint from:sourceView 
-               with:[:o | okAction. ^ true]
-               ifFail:[:o | failAction. ^ false].
+    failAction value.
     ^ false
 
-
-
-
-
+    "Modified: 4.4.1997 / 18:25:18 / cg"
 !
 
 handlesButtonMotion:button inView:aView
@@ -616,32 +624,60 @@
     destinationView := device viewFromId:lastViewId.
     destinationId := lastViewId.
 
-    "into another one"
+    dropAction notNil ifTrue:[
+        "/ initiator wants to do it himself, manually.
+
+        dropAction value:destinationView
+                   value:destinationId
+                   value:rootPoint
+                   value:destinationPoint.
+        ^ self
+    ].
+
+    "/ default drop behavior:
+    "/ if its one of my own views, ask if dropping is ok.
+    "/ if not, ask the device to drop it.
+
     destinationView notNil ifTrue:[
+        "/
+        "/ one of my views
+        "/
         destinationPoint := device translatePoint:rootPoint
                                              from:(rootView id) 
                                                to:(destinationView id).
         destinationView transformation notNil ifTrue:[
             destinationPoint := destinationView transformation applyInverseTo:destinationPoint
-        ]
-    ] ifFalse:[
-        "
-         not one of my views
-        "
-    ].
+        ].
+
+        (destinationView canDrop:dropObjects) ifTrue:[
+            destinationView drop:dropObjects at:destinationPoint.
+            ^ self.
+        ].
 
-    dropAction isNil ifTrue:[
-        "/ XXX add external clipboard mechanism via display
-        (destinationView notNil and:[destinationView canDrop:dropObjects]) ifTrue:[
-            destinationView drop:dropObjects at:destinationPoint
+        "/ try superViews along the chain ...
+        destinationView := destinationView superView.
+        [destinationView notNil] whileTrue:[
+            (destinationView canDrop:dropObjects) ifTrue:[
+                destinationView drop:dropObjects at:nil.
+                ^ self.
+            ].
+            destinationView := destinationView superView.
         ].
         ^ self
     ].
 
-    dropAction value:destinationView
-               value:destinationId
-               value:rootPoint
-               value:destinationPoint
+    "/
+    "/ not one of my views
+    "/
+
+    "/ XXX add external clipboard mechanism via display
+    device 
+        drop:dropObjects 
+        inWindowID:destinationId 
+        position:destinationPoint 
+        rootPosition:rootPoint
+
+    "Modified: 4.4.1997 / 18:32:43 / cg"
 !
 
 uncatchEvents
@@ -682,6 +718,22 @@
     "
 ! !
 
+!DragAndDropManager::DemoView3 methodsFor:'events'!
+
+buttonPress:button x:x y:y
+    DragAndDropManager new
+        startArrowDragIn:self 
+        at:(x@y)
+        atEnd:[:view
+               :viewID
+               :rootPoint
+               :viewPoint | ]
+
+    "
+     self new open
+    "
+! !
+
 !DragAndDropManager::DemoView2 methodsFor:'events'!
 
 buttonPress:button x:x y:y
@@ -702,24 +754,8 @@
 
 ! !
 
-!DragAndDropManager::DemoView3 methodsFor:'events'!
-
-buttonPress:button x:x y:y
-    DragAndDropManager new
-        startArrowDragIn:self 
-        at:(x@y)
-        atEnd:[:view
-               :viewID
-               :rootPoint
-               :viewPoint | ]
-
-    "
-     self new open
-    "
-! !
-
 !DragAndDropManager class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.10 1997-02-11 19:09:24 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.11 1997-04-04 23:59:02 cg Exp $'
 ! !