--- a/EditTextView.st Mon Jan 09 09:49:39 2006 +0100
+++ b/EditTextView.st Tue Jan 10 14:31:41 2006 +0100
@@ -2077,66 +2077,79 @@
!EditTextView methodsFor:'drag & drop'!
allowDrop:aBoolean
- "enable/disable drop support
- "
+ "enable/disable drop support"
+
aBoolean ifFalse:[
- dropTarget := nil.
+ dropTarget := nil.
] ifTrue:[
- dropTarget ifNil:[
- dropTarget := DropTarget receiver:self
- argument:nil
- dropSelector:#'drop:'
- canDropSelector:#'canDrop:'
- ]
- ].
-!
-
-canDrop:aContext
- "I accept textObjects and fileObjects only
- "
+ dropTarget ifNil:[
+ dropTarget := DropTarget receiver:self
+ argument:nil
+ dropSelector:#'drop:'
+ canDropSelector:#'canDrop:'
+ ]
+ ].
+!
+
+canDrop:aDropContextOrCollectionOfDropObjects
+ "I accept textObjects and fileObjects only.
+ For bw. compatibility, also collections of drop objects are handled (may vanish)"
+
|objects|
- aContext sourceWidget == self ifTrue:[
- ^ false
- ].
self checkModificationsAllowed ifFalse:[^ false].
- objects := aContext dropObjects.
+ aDropContextOrCollectionOfDropObjects isCollection ifTrue:[
+ objects := aDropContextOrCollectionOfDropObjects.
+ ] ifFalse:[
+ aDropContextOrCollectionOfDropObjects sourceWidget == self ifTrue:[^ false].
+
+ objects := aDropContextOrCollectionOfDropObjects dropObjects.
+ ].
+
objects isEmpty ifTrue:[ ^ false ].
objects do:[:el|
- (el isTextObject or:[el isFileObject]) ifFalse:[^ false].
+ (el isTextObject or:[el isFileObject]) ifFalse:[^ false].
].
^ true
!
-drop:aContext
+drop:aDropContextOrCollectionOfDropObjects at:aPoint
"drop objects
- "
- |text|
-
- (self canDrop:aContext) ifFalse:[^ false].
+ For bw. compatibility, also collections of drop objects are handled (may vanish)"
+
+ |text objects|
+
+ (self canDrop:aDropContextOrCollectionOfDropObjects) ifFalse:[^ self].
+
+ aDropContextOrCollectionOfDropObjects isCollection ifTrue:[
+ objects := aDropContextOrCollectionOfDropObjects.
+ ] ifFalse:[
+ objects := aDropContextOrCollectionOfDropObjects dropObjects.
+ ].
text := StringCollection new.
- aContext dropObjects do:[:el| |obj|
- obj := el theObject.
- el isTextObject ifTrue:[ text addAll:obj ]
- ifFalse:[ text add:(obj asString) ]
+ objects do:[:el|
+ |obj|
+
+ obj := el theObject.
+ el isTextObject ifTrue:[ text addAll:obj ]
+ ifFalse:[ text add:(obj asString) ]
].
self pasteOrReplace:text.
- ^ true
!
dropTarget
- "returns the dropTarget or nil
- "
+ "returns the dropTarget or nil"
+
^ dropTarget
!
dropTarget:aDropTragetOrNil
- "set the dropTarget or nil
- "
+ "set the dropTarget or nil"
+
dropTarget := aDropTragetOrNil.
! !
@@ -4600,7 +4613,7 @@
trimBlankLines := self st80EditMode not. "true."
cursorMovementWhenUpdating := #beginOfText.
- "/ on default enable drop
+ "/ enable drop by default
self allowDrop:true. "/ readOnly tested in #canDrop:
undoSupport := UndoSupport for:self.
@@ -6514,5 +6527,5 @@
!EditTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.383 2006-01-09 08:48:56 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.384 2006-01-10 13:31:41 cg Exp $'
! !