#OTHER by cg
authorClaus Gittinger <cg@exept.de>
Fri, 15 Jun 2018 02:48:47 +0200
changeset 4131 8ad89f6c14a4
parent 4130 cc5749e7c679
child 4133 fa8e63e8a6b2
#OTHER by cg drag and drop confusion fixed (Logical vs. Device coordinates)
DropContext.st
--- a/DropContext.st	Thu Jun 14 14:39:38 2018 +0200
+++ b/DropContext.st	Fri Jun 15 02:48:47 2018 +0200
@@ -182,7 +182,7 @@
 !
 
 targetPoint
-    "returns the relative point on the target widget (in DEVICE coordinates)"
+    "returns the point on the target widget (in LOGICAL coordinates)"
 
     |trn org pnt dev|
 
@@ -191,23 +191,36 @@
     dev := sourceWidget device.
     pnt := dev translatePoint:rootPoint from:(dev rootWindowId) to:targetId.
 
-    "/ cg: why do you applyInverse below??
-    "/ pnt is already coming in device coordinates from translatePoint:from:to: 
-    "/ so the applyInverse is completely bogus !!!!!!
-
-    false "(pnt notNil and:[targetWidget notNil])" ifTrue:[
+    "/ aha: the comment which was previously above was WRONG!!
+    "/ the targetPoint is in LOGICAL coordinates NOT in device coordinates
+    
+    (pnt notNil and:[targetWidget notNil]) ifTrue:[
         (trn := targetWidget transformation) notNil ifTrue:[
             ^ trn applyInverseTo:pnt.
         ].
-        "/ ca: do not translate here - drop is in device coordinates EVERYWHERE
-        "/ (org := targetWidget viewOrigin) notNil ifTrue:[
-        "/     ^ pnt + org.
-        "/ ].
+        (org := targetWidget viewOrigin) notNil ifTrue:[
+            ^ pnt + org.
+        ].
     ].
     "/ Transcript show:'targetPnt: '; showCR:pnt.
     ^ pnt
 
-    "Modified: / 14-06-2018 / 14:39:27 / Claus Gittinger"
+    "Modified (comment): / 15-06-2018 / 02:31:35 / Claus Gittinger"
+!
+
+targetPointInDeviceCoordinates
+    "returns the point on the target widget (in DEVICE coordinates)"
+
+    |pnt dev|
+
+    rootPoint isNil ifTrue:[^ nil].
+
+    dev := sourceWidget device.
+    pnt := dev translatePoint:rootPoint from:(dev rootWindowId) to:targetId.
+
+    ^ pnt
+
+    "Created: / 15-06-2018 / 02:22:12 / Claus Gittinger"
 !
 
 targetWidget