--- a/DragAndDropManager.st Tue Jan 24 11:34:04 2006 +0100
+++ b/DragAndDropManager.st Tue Jan 24 17:53:42 2006 +0100
@@ -733,6 +733,94 @@
!DragAndDropManager methodsFor:'accessing'!
+buttonMotion:button x:x y:y view:aView
+ |device screenPoint oldWidget oldId oldPoint newId newWidget oldTarget newTarget
+ isDroppable cursor|
+
+ self isDisabled ifTrue: [ ^ self ].
+
+ escapePressed == true ifTrue:[
+ self removePassiveAction.
+ ^ self
+ ].
+
+ (dragView notNil and:[dragView sensor motionEventPending]) ifTrue:[
+ ^ self
+ ].
+ self removePassiveAction.
+
+ device := dragView device.
+ oldWidget := dropContext targetWidget.
+ oldId := dropContext targetId.
+ oldPoint := dropContext rootPoint.
+
+ screenPoint := self class translatePointToScreen:(x @ y) from:aView.
+"/ screenPoint := device pointerPosition.
+ dropContext rootPoint:screenPoint.
+
+ newId := device viewIdFromPoint:screenPoint.
+ newWidget := device viewFromId:newId.
+
+ dropContext rootPoint:screenPoint.
+ dropContext targetWidget:newWidget id:newId.
+
+ handler isInterestedInDropTarget ifFalse:[
+ "/
+ "/ line or arrow handler
+ "/
+ handler dragTo:screenPoint.
+ ^ self
+ ].
+
+ oldTarget := dropContext dropTarget.
+ newTarget := self doFindDropTargetIn:newWidget at:screenPoint.
+
+ newTarget ~= oldTarget ifTrue:[
+ "/
+ "/ drop target changed: handler might restore the screen
+ "/
+ handler dropTargetWillChange.
+
+ oldTarget notNil ifTrue:[
+ "/
+ "/ setup old context
+ "/
+ dropContext targetWidget:oldWidget id:oldId.
+ oldTarget leave:dropContext.
+ dropContext targetWidget:newWidget id:newId.
+ ].
+ dropContext dropTarget:newTarget.
+ newTarget notNil ifTrue:[ newTarget enter:dropContext ]
+ ] ifFalse:[
+ dropContext dropTarget:newTarget
+ ].
+
+ "/
+ "/ update the cursor
+ "/
+ (isDroppable := dropContext canDrop) ifTrue:[
+ cursor := enabledCursor
+ ] ifFalse:[
+ dropContext isAlienView ifFalse:[cursor := disabledCursor]
+ ifTrue:[cursor := alienCursor]
+ ].
+
+ dragView cursor:cursor now:true.
+ "/
+ "/ test if droppable state changed
+ "/
+ canDrop == isDroppable ifFalse:[
+ "/
+ "/ droppable state changed: handler might restore the screen
+ "/
+ canDrop := isDroppable.
+ handler dropTargetWillChange
+ ].
+
+ newTarget notNil ifTrue:[ newTarget over:dropContext ].
+ handler dragTo:screenPoint.
+!
+
device
"returns the device of the source view"
@@ -785,6 +873,10 @@
^ dragView font
!
+isDisabled
+ ^ disabledFlag ? false
+!
+
passiveAction:aBlockOrNil
self removePassiveAction.
aBlockOrNil notNil ifTrue:[
@@ -1148,93 +1240,6 @@
!DragAndDropManager methodsFor:'event catching'!
-buttonMotion:button x:x y:y view:aView
- |device screenPoint oldWg oldId oldPt newId newWg oldTgt newTgt isDroppable cursor|
-
- self disabledFlag ifTrue: [
- ^ self
- ].
- escapePressed == true ifTrue:[
- self removePassiveAction.
- ^ self
- ].
-
- (dragView notNil and:[dragView sensor motionEventPending]) ifTrue:[
- ^ self
- ].
- self removePassiveAction.
-
- device := dragView device.
- oldWg := dropContext targetWidget.
- oldId := dropContext targetId.
- oldPt := dropContext rootPoint.
-
- screenPoint := self class translatePointToScreen:(x @ y) from:aView.
-"/ screenPoint := device pointerPosition.
- dropContext rootPoint:screenPoint.
-
- newId := device viewIdFromPoint:screenPoint.
- newWg := device viewFromId:newId.
-
- dropContext rootPoint:screenPoint.
- dropContext targetWidget:newWg id:newId.
-
- handler isInterestedInDropTarget ifFalse:[
- "/
- "/ line or arrow handler
- "/
- handler dragTo:screenPoint.
- ^ self
- ].
- oldTgt := dropContext dropTarget.
- newTgt := self doFindDropTargetIn:newWg at:screenPoint.
-
- newTgt ~= oldTgt ifTrue:[
- "/
- "/ drop target changed: handler might restore the screen
- "/
- handler dropTargetWillChange.
-
- oldTgt notNil ifTrue:[
- "/
- "/ setup old context
- "/
- dropContext targetWidget:oldWg id:oldId.
- oldTgt leave:dropContext.
- dropContext targetWidget:newWg id:newId.
- ].
- dropContext dropTarget:newTgt.
- newTgt notNil ifTrue:[ newTgt enter:dropContext ]
- ] ifFalse:[
- dropContext dropTarget:newTgt
- ].
-
- "/
- "/ update the cursor
- "/
-
- (isDroppable := dropContext canDrop) ifTrue:[
- cursor := enabledCursor
- ] ifFalse:[
- dropContext isAlienView ifFalse:[cursor := disabledCursor]
- ifTrue:[cursor := alienCursor]
- ].
- dragView cursor:cursor now:true.
- "/
- "/ test if droppable state changed
- "/
- canDrop == isDroppable ifFalse:[
- "/
- "/ droppable state changed: handler might restore the screen
- "/
- canDrop := isDroppable.
- handler dropTargetWillChange
- ].
-
- newTgt notNil ifTrue:[ newTgt over:dropContext ].
- handler dragTo:screenPoint.
-!
-
buttonRelease:button x:x y:y view:aView
|targetWidget|
@@ -1414,36 +1419,41 @@
doFindDropTargetIn:aView at:aPoint
"get the drop target for a view and source at a point or nil"
+ |target|
+
aView isNil ifTrue:[ ^ nil ].
"/
"/ new mechanism to get a dropTarget
"/
- MessageNotUnderstood
- ignoreNotUnderstoodOf:#dropTarget
- in:[ |target|
- target := aView dropTarget.
- target notNil ifTrue:[ ^ target ].
- ].
+ target := aView dropTarget.
+ target notNil ifTrue:[
+ ^ target
+ ].
"/
"/ old mechanism to get a dropTarget
"/
- DragContextQuerySignal answer:dropContext do:[
- DragOriginatorQuerySignal answer:dragView do:[
- DragOffsetQuerySignal answer:dragOffset do:[
- |view dobj|
+ (SignalSet
+ with:DragContextQuerySignal
+ with:DragOriginatorQuerySignal
+ with:DragOffsetQuerySignal)
+ handle:[:ex |
+ ex signal == DragContextQuerySignal ifTrue:[ ex proceedWith:dropContext].
+ ex signal == DragOriginatorQuerySignal ifTrue:[ ex proceedWith:dragView].
+ ex signal == DragOffsetQuerySignal ifTrue:[ ex proceedWith:dragOffset].
+ self error.
+ ] do:[
+ |view dobj|
- view := aView.
- dobj := dropContext dropObjects.
- [
- (view canDrop:dobj) ifTrue:[
- ^ DropTarget receiver:self argument:view dropSelector:#doDrop:in:.
- ].
- (view := view superView) notNil
- ] whileTrue.
- ]
- ].
+ view := aView.
+ dobj := dropContext dropObjects.
+ [
+ (view canDrop:dobj) ifTrue:[
+ ^ DropTarget receiver:self argument:view dropSelector:#doDrop:in:.
+ ].
+ (view := view superView) notNil
+ ] whileTrue.
].
^ nil
!
@@ -1471,7 +1481,7 @@
dragView := aView.
dropAction := aFourArgEndBlock.
- windowGroup := aView windowGroup.
+ windowGroup := aView windowGroup.
handler := aHandler.
escapePressed := false.
@@ -1502,23 +1512,25 @@
device sync.
dragView sensor flushMotionEventsFor:nil.
- autoScrollTask := Process for:[
- [ |sensor|
+ autoScrollTask :=
+ [
+ [ |sensor|
- sensor := windowGroup sensor.
+ sensor := windowGroup sensor.
- [ self isActive ] whileTrue:[
- Delay waitForMilliseconds:(self class autoScrollDelayTimeMs).
+ [ self isActive ] whileTrue:[
+ Delay waitForMilliseconds:(self class autoScrollDelayTimeMs).
- self isActive ifTrue:[
- sensor pushUserEvent:#processAutoScroll for:self.
+ self isActive ifTrue:[
+ sensor pushUserEvent:#processAutoScroll for:self.
+ ].
].
- ].
- ]ensure:[
- autoScrollTask := nil.
- ]
- ] priority:(Processor userSchedulingPriority).
+ ]ensure:[
+ autoScrollTask := nil.
+ ]
+ ] newProcess.
+ autoScrollTask priority:(Processor userSchedulingPriority).
autoScrollTask name:'Drag-AutoScroll'.
autoScrollTask resume.
@@ -1557,7 +1569,7 @@
!DragAndDropManager class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.67 2006-01-10 09:47:40 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.68 2006-01-24 16:52:17 cg Exp $'
! !
DragAndDropManager initialize!