drag and findObject fixes
authorClaus Gittinger <cg@exept.de>
Mon, 07 Jan 2008 14:47:53 +0100
changeset 3530 2cac95ddc118
parent 3529 bcf8c2053ac4
child 3531 2cfac8dca1ef
drag and findObject fixes
ObjectView.st
--- a/ObjectView.st	Mon Jan 07 14:45:24 2008 +0100
+++ b/ObjectView.st	Mon Jan 07 14:47:53 2008 +0100
@@ -979,7 +979,7 @@
             ] 
         ].
         self setDefaultActions.
-        movedObject := nil
+        movedObject := nil.
     ]
 
     "Modified: / 10.10.2001 / 14:43:09 / cg"
@@ -1107,6 +1107,16 @@
 
     self invertDragRectangle.
     self cursor:oldCursor.
+    dragObject width < 0 ifTrue:[
+        dragObject 
+                origin:(dragObject origin + (dragObject width@0))
+                corner:(dragObject corner - (dragObject width@0))
+    ].
+    dragObject height < 0 ifTrue:[
+        dragObject 
+                origin:(dragObject origin + (0@dragObject height))
+                corner:(dragObject corner - (0@dragObject height))
+    ].
     self selectAllIn:dragObject.
 
     releaseAction := nil.
@@ -3072,12 +3082,16 @@
     "for all objects (by enumerating from back to front) which are hit by
      the argument, aPoint, evaluate aBlock"
 
-    |hdelta|
+    self allObjectsHitAt:aPoint withDelta:(self hitDelta / self scale x) do:aBlock
+!
+
+allObjectsHitAt:aPoint withDelta:hDelta do:aBlock
+    "for all objects (by enumerating from back to front) which are hit by
+     the argument, aPoint, evaluate aBlock"
 
     contents notEmptyOrNil ifTrue:[
-        hdelta := self hitDelta / self scale x.
         contents reverseDo:[:object |
-            (object isHitBy:aPoint withDelta:hdelta) ifTrue:[
+            (object isHitBy:aPoint withDelta:hDelta) ifTrue:[
                 aBlock value:object
             ]
         ]
@@ -3116,6 +3130,18 @@
     "Created: / 4.7.1999 / 18:51:29 / cg"
 !
 
+findNearestObjectAt:aPoint
+    "find the nearest object (by looking from back to front) which is hit by
+     the argument, aPoint - this is the topmost object hit"
+
+    0 to:(self hitDelta) by:(1 / 2) do:[:hdelta |
+        self allObjectsHitAt:aPoint withDelta:(hdelta " / self scale x") do:[:object | ^ object].
+    ].
+    ^ nil
+
+    "Modified: / 27-10-2006 / 16:58:54 / cg"
+!
+
 findObjectAt:aPoint
     "find the last object (by looking from back to front) which is hit by
      the argument, aPoint - this is the topmost object hit"
@@ -3173,6 +3199,12 @@
     "Modified: / 27-10-2006 / 17:01:47 / cg"
 !
 
+findObjectForSelectAt:aPoint
+    "find the object for a select"
+
+    ^ self findObjectAt:aPoint
+!
+
 frameIncludesSelectionHandlesOn:anObject
     "return true, if anObjects frame includes any selection
      handles, false if not or if we do not know.
@@ -3333,11 +3365,15 @@
 
     |anObject|
 
-    anObject := self findObjectAt:aPoint.
+    anObject := self findObjectForSelectAt:aPoint.
     anObject notNil ifTrue:[
-	(self isSelected:anObject) ifFalse:[self unselect].
-	self startObjectMove:anObject at:aPoint.
-	^ self
+        (self isSelected:anObject) ifFalse:[
+            self unselect.
+            self startObjectMove:anObject at:aPoint.
+        ] ifTrue:[
+            self startObjectMove:selection at:aPoint.
+        ].
+        ^ self
     ].
     "nothing was hit by this click - this starts a group select"
     self unselect.
@@ -3441,5 +3477,5 @@
 !ObjectView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.125 2007-05-31 15:28:54 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.126 2008-01-07 13:47:53 cg Exp $'
 ! !