Dragging images in a revlet

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
drpj
Posts: 2
Joined: Mon Apr 26, 2010 9:58 pm

Dragging images in a revlet

Post by drpj » Mon Apr 26, 2010 10:08 pm

I have created a simple stack that allows me to drag a small icon around and drop it in a different location. When I save this as a web application, however, the dragging does not work. The icon is a gif image imported as a control. Here's the script that works in development mode but not as a web app.

on dragStart
set the dragData["image"] to id of image "dress1.gif"
set the dragImage to the id of image "dress1_drag.png" of me
end dragStart
on dragEnd
set the location of me to the mouseloc
set the layer of me to top
end dragEnd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Dragging images in a revlet

Post by bn » Mon Apr 26, 2010 11:18 pm

Hi drpj,
welcome to the forum.
As far as I can see you only want to grab an object and drag it to another place. Wouldn't

Code: Select all

on mouseDown
   set the layer of me to top
   grab me
end mouseDown
do what you want. I did not test drag in a revlet but grab works in a revlet.
if you want to change the size and transparency of the image you could say:

Code: Select all

local sMyWidth, sMyHeight

on mouseDown
   lock screen
   put the width of me into sMyWidth
   put the height of me into sMyHeight
   set the width of me to round(sMyWidth/2)
   set the height of me to round(sMyHeight/2)
   set the blendlevel of me to 50
   set the layer of me to top
   grab me
   unlock screen
end mouseDown

on mouseUp
   lock screen
   set the width of me to sMyWidth
   set the height of me to sMyHeight
   set the blendlevel of me to 0
end mouseUp
regards
Bernd

drpj
Posts: 2
Joined: Mon Apr 26, 2010 9:58 pm

Re: Dragging images in a revlet

Post by drpj » Tue Apr 27, 2010 1:23 am

Your code would work, and that is how I would have done it in HyperCard. But i was hoping to take advantage of the dragImage property by dragging a gray version of the image. I know I could do this all programmatically, but then, what's the point of the dragStart, dragEnd, dragImage, etc. They are such nice features.

I'm about to upgrade to Studio. Do you know if what I want to do with the drag... commands will work with that version of Rev?

Thanks, btw, for your quick reply.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Dragging images in a revlet

Post by bn » Tue Apr 27, 2010 10:00 am

Hi drpj,
I never did much with drag and drop. Since I am lazy I do this kind of stuff with grab. I tried to figure out what I gather what you are trying to do. And do it with drag. I might be off.

Code: Select all

local sX, sY
on dragStart
   put the clickLoc into tClick
   put the loc of me into tMyLoc
   put item 1 of tMyLoc - item 1 of tClick into sX
   put item 2 of tMyLoc - item 2 of tClick into sY
   set the dragData["image"] to id of image "dress1.gif"
   set the dragImage to the id of image "dress1_drag.png" 
   set the dragImageOffset to (round (width of image "dress1_drag.png"/2))-sX, (round (height of image "dress1_drag.png"/2))-sY
end dragStart

on dragEnd
   put the mouseLoc into tMouseLoc
   add sX to item 1 of tMouseLoc
   add sY to item 2 of tMouseLoc
   set the location of me to tMouseLoc
   set the layer of me to top
end dragEnd
In your original posting there was a line of code
drpj wrote:set the dragImage to the id of image "dress1_drag.png" of me
I dont think this works with "of me" or I misunderstand something.
As far as I know drag and drop behaves the same in Rev Media and Rev Studio.

I tried the 'drag and drop' variant in a revlet with Rev Enterprise 4.0 on a Mac and it did not work for me in the revlet either. The grab variants work. The documentation states that drag and drop works on desktop and sever, not web.

regards
Bernd

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Dragging images in a revlet

Post by Klaus » Tue Apr 27, 2010 12:00 pm

Hi all,

Drag'n'Drop is not (yet) supported in Revlets!


Best

Klaus

Post Reply