Getting drag and drop to copy (not cut) dragged text
Dave Cragg
dcragg at lacscentre.co.uk
Sun Oct 26 09:20:02 EST 2003
At 6:57 pm +0000 25/10/03, depstein at att.net wrote:
>I am trying to override this behavior when text is dropped to a locked field,
>i.e., I want the dragged text to be displayed in
>the locked field but remain, still selected,
>where it was in the original field. The following procedure does not work:
>
>In the card script:
>
>on dragStart
> global textBuffer,locBuffer,chunkBuffer
>-- these globals are used to record the starting
>condition of the field being dragged from:
> put the text of the target into textBuffer
> put the selectedChunk into chunkBuffer
> put the long name of the target into locBuffer
> pass dragStart
>end dragStart
>
>In the script of a locked field:
>
>on dragEnter
> set the acceptDrop to true
>end dragEnter
>
>on dragDrop
> global textBuffer,locBuffer,chunkBuffer
> put the dragData["text"] into me -- This works as expected.
> -- Now try to restore the pre-drag content and
>selection of the source field:
> do "put textBuffer into" && locBuffer
> do "select" && chunkBuffer
>-- But this doesn't happen. The source field
>has lost the text that was dragged out.
>end dragDrop
>
>Can anyone explain what's going wrong and how to fix this?
This seems to work:
In your card script:
on dragStart
set the dragData["text"] to the selection
## don't pass this message
end dragStart
on dragEnd
## need to trap this to stop automatic behavior
end dragEnd
In the locked field:
on dragEnter
set the acceptDrop to true
end dragEnter
on dragDrop
put the dragData["text"] into me
end dragDrop
It seems you don't need to reselect the original
selection. However, I guess that might depend on
what you were doing in the dragDrop handler. But
I think the dragEnd handler would be the place to
do that.
Cheers
Dave
More information about the metacard
mailing list