Drag-And-Drop Image Fun

Igor Couto igor at pixelmedia.com.au
Wed May 28 08:22:00 EDT 2003


Dear Robert,

Thank you for your reply:

On Wednesday, May 28, 2003, at 10:59  PM, Robert Brenstein wrote:

> I think if you search list archives for DragDrop you will find an 
> example of dragging a text or text field.
>

I have been able to successfully work with drag-and-drop with text, but 
not with PICTURES. My original posting, in regards to the 2 problems I 
encountered with drag-and-drop:

PROBLEM 1:
I'm having trouble dragging IMAGE information. I want to allow the user 
to drag an image onto an 'imageWell' object. I'M STARTING THE DRAG 
INSIDE REVOLUTION, and the dragSource is an image object. The imageWell 
is another image object, and should accept the drag if there is image 
information in the dragged object (the dragData). Upon drop, the 
imageWell should display the image. My problem is that the 
documentation is a bit unclear as to WHAT exactly it is that I should 
be putting into the dragData["image"].  The documentation merely states 
the the dragData["image"] should contain 'an image in PNG format'. So, 
here is what I tried:

a) Make new stack. Place a ',png' image in it (our 'source'), and place 
an 'empty' image object somewhere else in the card (our 'target' 
object) - which will be our 'imageWell'.

b) In the source image, as per instructions in the language guide, I 
added the following script:

on mouseDown
    set the dragData["image"] to me
end mouseDown

c) In the target image, I added the following script:

on dragEnter
    if dragData["image"' is not empty then set the showBorder of me to 
true
end dragEnter

on dragLeave
    set the showBorder of me to false
end dragLeave

on dragDrop
   put dragData["image"] into me
end dragDrop

This doesn't work. It appears that dragData["image"] is empty, as there 
is no change in the appearance of the target image. So I tried changing 
mouseDown handler of the source image, so that what is stored is the 
'imageData':

on mouseDown
    set the dragData["image"] to the imageData of me
end mouseDown

No change - except that it does something nasty to Revolution (changes 
cursors, slows it down) and I have to quite and re-launch... I cannot 
find any other hints in the documentation as to what it is that I 
should be doing. Could anyone shed some light?


PROBLEM 2:
In MacOS X, when a user drags an item, there is usually quite a bit of 
visual feedback given to the user. When a user is dragging something, 
there is usually a transparent image right underneath the cursor, 
giving the user some visual hint as to WHAT is being dragged.
It seems to me that in RunRev, the only visual feedback we can give the 
user is by changing the cursor image... Is that correct? - or would 
there be a way to drag a custom 'transparent image', like in OS X, 
while dragging between windows and applications?


Any suggestions or hints on either problem much appreciated.


--
Igor de Oliveira Couto
----------------------------------
igor at pixelmedia.com.au
----------------------------------




More information about the use-livecode mailing list