Drag and drop from a list field

Ken Ray kray at sonsothunder.com
Tue Feb 27 11:17:34 EST 2007


On Mon, 26 Feb 2007 21:39:29 -0800, Bill Vlahos wrote:

> Klaus has a great demo stack in RevOnLine on dragging and dropping a 
> file on the computer desktop into a field or stack. What I want to 
> know is how to drag and drop out of a list field onto the desktop.
> 
> There is a sample drag and drop in the Rev docs using graphics 
> objects for dragging the name of a color graphic to another object on 
> the same card. Essentially the object has the script:
> 
> on mouseDown
>   set the dragData["text"] to the short name of the target
>   set the borderWidth of the target to 3
> end mouseDown
> 
> on dragEnd
>   set the borderWidth of the target to 1
> end dragEnd
> 
> 
> I have two questions.
> 
> 1. How do I get the content of the line of text (the one that is 
> selected) in a list field that I want to drag from?

You could:

  set the dragData["text"] to the hilitedText of the target

However, the cursor changes to be the "can't drag" cursor, even though 
you can drop the text into the Message Box or another app without a 
problem, so you'd have to change the cursor too:

on mouseDown
  lock cursor
  set cursor to arrow
  set the dragData["text"] to the hilitedText of the target
end mouseDown

The problem with *that* is that you're releasing outside of the main 
card window, so no mouseUp/mouseRelease message will be sent. So you'd 
need to poll for the mouseState like this:

on mouseDown
  lock cursor
  set cursor to 24   -- the drag cursor
  send "checkMouse" to me in 100 milliseconds
  set the dragData["text"] to the hilitedText of the target
end mouseDown

on checkMouse
  if the mouse is up then
    unlock cursor
  else
    send "checkMouse" to me in 100 milliseconds
  end if
end checkMouse

> 2. How do I send it outside the stack to the desktop to make a file 
> on the desktop?

Well, if you're just dragging text, then the OS does it for you - when 
you drag text into the Finder (or Windows Explorer) and release, it 
will make a clipping file for you - basically it detects the type of 
dragData ("text" in this case), and handles it for you. However I don't 
know how to find out exactly *where* the file ends up. That is, what 
folder, etc. received the clipping.

It would really be great if the "dragDestination" could be updated to 
contain this kind of information, but right now the destination can 
only be other objects in Rev.

Anyone have any ideas on how to find out where the clipping was dropped?

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/



More information about the Use-livecode mailing list