--- a/ObjectView.st Mon Jul 18 16:23:32 2005 +0200
+++ b/ObjectView.st Fri Jul 22 11:41:35 2005 +0200
@@ -18,8 +18,8 @@
keyPressAction selection gridShown gridPixmap scaleMetric
dragObject leftHandCursor oldCursor movedObject moveStartPoint
moveDelta documentFormat canDragOutOfView rootMotion rootView
- aligning gridAlign aligningMove'
- classVariableNames:''
+ aligning gridAlign aligningMove inMotion buttonPressTime'
+ classVariableNames:'MIN_DELTA_FOR_MOVE TIME_DELTA_FOR_MOVE'
poolDictionaries:''
category:'Views-Basic'
!
@@ -322,6 +322,14 @@
0 is exact; 1*pixelPerMillimeter is good for draw programs"
^ 0
+!
+
+mouseMotionDeltaForMove
+ ^ MIN_DELTA_FOR_MOVE ? 10
+!
+
+mouseMotionTimeDeltaForMove
+ ^ TIME_DELTA_FOR_MOVE ? 500
! !
!ObjectView methodsFor:'accessing'!
@@ -376,6 +384,8 @@
setDefaultActions
"setup actions for default behavior (do - nothing)"
+ movedObject := nil.
+ inMotion := false.
motionAction := [:movePoint | nil].
releaseAction := [nil]
@@ -1011,8 +1021,17 @@
method, to make the view start to drag some object.
See startObjectMove and startRootObjectMove."
- motionAction := [:movePoint | self doObjectMove:movePoint].
- releaseAction := [self endObjectMove]
+ |didStartMove|
+
+ didStartMove := false.
+ motionAction := [:movePoint |
+ didStartMove := true.
+ self doObjectMove:movePoint
+ ].
+ releaseAction := [ didStartMove
+ ifTrue:[ self endObjectMove ]
+ ifFalse:[self setDefaultActions]
+ ]
!
startObjectMove:something at:aPoint
@@ -1339,16 +1358,14 @@
"user pressed left button with ctrl"
ctrlPressAction notNil ifTrue:[
- lastButt := x @ y.
ctrlPressAction value:lastButt.
- ^ self
]
!
buttonMotion:buttonState x:buttX y:buttY
"user moved mouse while button pressed"
- |xpos ypos movePoint limitW limitH|
+ |xpos ypos movePoint limitW limitH minDeltaForMotion|
"is it the select or 1-button ?"
buttonState == 0 ifTrue:[^ self].
@@ -1378,15 +1395,28 @@
(ypos > limitH) ifTrue:[ypos := limitH]
]
].
+
movePoint := xpos @ ypos.
- (xpos == (lastButt x)) ifTrue:[
- (ypos == (lastButt y)) ifTrue:[
- ^ self "no move"
- ]
+ "/ if the motion is more than mouseMotionDeltaForMove
+ "/ or the time-delta is longer than timeDeltaForMove
+ (Timestamp now millisecondDeltaFrom:buttonPressTime) > self class mouseMotionTimeDeltaForMove ifFalse:[
+ inMotion == true ifTrue:[
+ minDeltaForMotion := 1
+ ] ifFalse:[
+ minDeltaForMotion := self class mouseMotionDeltaForMove
+ ].
+ transformation notNil ifTrue:[
+ minDeltaForMotion := transformation applyInverseToX:minDeltaForMotion.
+ ].
+ ((xpos - (lastButt x)) abs < minDeltaForMotion
+ and:[ (ypos - (lastButt y)) abs < minDeltaForMotion]) ifTrue:[
+ ^ self "no (ignored) move"
+ ].
].
motionAction notNil ifTrue:[
+ inMotion := true.
motionAction value:movePoint.
lastButt := movePoint.
^ self
@@ -1416,6 +1446,9 @@
"user pressed left button"
((button == 1) or:[button == #select]) ifTrue:[
+ lastButt := x @ y.
+ buttonPressTime := Timestamp now.
+
self sensor shiftDown ifTrue:[
^ self buttonShiftPress:button x:x y:y
].
@@ -1424,7 +1457,6 @@
].
pressAction notNil ifTrue:[
- lastButt := x @ y.
pressAction value:lastButt.
^ self
]
@@ -1435,6 +1467,9 @@
!
buttonRelease:button x:x y:y
+ inMotion := false.
+ lastButt := nil.
+
((button == 1) or:[button == #select]) ifTrue:[
releaseAction notNil ifTrue:[
releaseAction value.
@@ -1450,9 +1485,7 @@
"user pressed left button with shift"
shiftPressAction notNil ifTrue:[
- lastButt := x @ y.
shiftPressAction value:lastButt.
- ^ self
]
"Modified: 1.8.1996 / 19:13:19 / cg"
@@ -1836,6 +1869,7 @@
sorted := false.
aligning := false.
aligningMove := false.
+ inMotion := false.
"Modified: 20.1.1997 / 20:41:10 / cg"
!
@@ -3342,5 +3376,5 @@
!ObjectView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.108 2005-05-09 07:26:31 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.109 2005-07-22 09:41:35 cg Exp $'
! !