--- a/DragAndDropManager.st Fri Sep 13 15:44:30 2002 +0200
+++ b/DragAndDropManager.st Mon Sep 16 12:17:07 2002 +0200
@@ -15,7 +15,7 @@
Object subclass:#DragAndDropManager
instanceVariableNames:'dropContext dragView dropAction dragOffset handler restoreBlock
- alienCursor enabledCursor disabledCursor canDrop'
+ alienCursor enabledCursor disabledCursor canDrop escapePressed'
classVariableNames:'DragContextQuerySignal DragOriginatorQuerySignal
DragOffsetQuerySignal ActiveDragAndDropManagers'
poolDictionaries:''
@@ -1093,6 +1093,8 @@
"
|oldPt oldTgt oldWg oldId newWg newId newTgt screenPoint cursor device isDroppable|
+ escapePressed == true ifTrue:[^ self].
+
device := dragView device.
screenPoint := self class translatePointToScreen:(x @ y) from:dragView.
"/ cursor := dragView cursor.
@@ -1191,7 +1193,7 @@
"button released; do the drop
"
((button == 2) or:[button == #menu]) ifTrue:[
- ^ self
+ ^ self
].
"/
"/ update the context
@@ -1202,21 +1204,22 @@
"/ restore source view
"/
restoreBlock value.
+ escapePressed == true ifTrue:[^ self].
"/
"/ at least do the drop operation
"/
dropAction isNil ifTrue:[
- dropContext doDrop
+ dropContext doDrop
] ifFalse:[
- "/
- "/ initiator wants to do it himself, manually.
- "/ Thus, no feedBack operation invoked.
- "/
- dropAction value:(dropContext targetWidget)
- value:(dropContext targetId)
- value:(dropContext rootPoint)
- value:(dropContext targetPoint).
+ "/
+ "/ initiator wants to do it himself, manually.
+ "/ Thus, no feedBack operation invoked.
+ "/
+ dropAction value:(dropContext targetWidget)
+ value:(dropContext targetId)
+ value:(dropContext rootPoint)
+ value:(dropContext targetPoint).
]
!
@@ -1250,6 +1253,28 @@
yes I am (to activate the clicked-on field)."
^ dragView == aView
+!
+
+handlesKeyPress:aKey inView:aView
+ "query from event processor: am I interested in key-events ?
+ yes I am (to activate the clicked-on field)."
+
+ ^ dragView == aView
+!
+
+keyPress:aKey x:x y:y view:aView
+ escapePressed == true ifTrue:[^ self ].
+
+ escapePressed := aKey == #Escape.
+
+ escapePressed ifFalse:[
+ ^ self
+ ].
+ handler ifNotNil:[
+ handler postDragging
+ ].
+"/ self buttonMotion:#select x:x y:y view:aView.
+"/ restoreBlock value.
! !
!DragAndDropManager methodsFor:'initialization'!
@@ -1336,7 +1361,7 @@
doStart:aHandler for:aView atEnd:aFourArgEndBlock
"setup a handler and a restore block
"
- |device savedCursor savedDelegate prevGrab sensor p|
+ |device savedCursor savedDelegate prevGrab prevKeyb sensor p|
device := aView device.
(ActiveDragAndDropManagers at:device ifAbsent:nil) notNil ifTrue:[
@@ -1353,13 +1378,17 @@
dropAction := aFourArgEndBlock.
savedCursor := aView cursor.
savedDelegate := aView delegate.
- handler := aHandler.
+ handler := aHandler.
+ escapePressed := false.
+ prevGrab := prevKeyb := nil.
dropContext dragHandler:aHandler.
restoreBlock := [
ActiveDragAndDropManagers removeKey:device ifAbsent:nil.
- aHandler postDragging.
+ escapePressed ifFalse:[
+ aHandler postDragging
+ ].
aView delegate:savedDelegate.
aView cursor:savedCursor now:true.
prevGrab notNil ifTrue:[
@@ -1368,12 +1397,20 @@
] ifFalse:[
aView ungrabPointer.
].
+ prevKeyb notNil ifTrue:[
+ aView forceUngrabKeyboard.
+ prevKeyb grabKeyboard.
+ ] ifFalse:[
+ aView ungrabKeyboard.
+ ].
].
aHandler preDraggingIn:aView.
aView delegate:self.
prevGrab := device activePointerGrab.
+ prevKeyb := device activeKeyboardGrab.
aView grabPointer.
+ aView grabKeyboard.
"/ must wait for all pending motion events to arrive, and ignore them
(sensor := aView sensor) notNil ifTrue:[
@@ -1409,6 +1446,6 @@
!DragAndDropManager class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.40 2002-09-13 13:44:19 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.41 2002-09-16 10:17:07 ca Exp $'
! !
DragAndDropManager initialize!