Making an image draggable

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Making an image draggable

Douglas Gilliland
I know it must be easy but I cannot figure out the script to make an
image of a metric ruler draggable so my students can drag it around
the screen to measure items in a quiz stack I am writing.
Tried several variations of the following script:
on mousedown
make image "ruler.jpg" draggable
end mousedown

Thanks for any help for this newbe.
Doug Gilliland
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Making an image draggable

Ken Ray
> Tried several variations of the following script:
> on mousedown
> make image "ruler.jpg" draggable
> end mousedown

-- Script of ruler image
on mouseDown
  grab me
end mouseDown

Now this doesn't have any constraints, but it works very well...

Ken Ray
Sons of Thunder Software
Email: [hidden email]
Web Site: http://www.sonsothunder.com/


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Making an image draggable

Eric Chatonet
In reply to this post by Douglas Gilliland
Hi Doug,

Here is a script I use in all my plug-ins to make their window  
"draggable":

local lAllowDrag -- local variable used by all handlers in the script
---------------------------------
on mouseDown
   put the mouseH & comma & the mouseV into lAllowDrag
end mouseDown
---------------------------------
on mouseMove x,y
   if lAllowDrag is empty then exit mouseMove
   set the topLeft of this stack to globalLoc(x - item 1 of  
lAllowDrag & comma & y - item 2 of lAllowDrag)
   -- in the script of your image: set the topLeft of me to...
end mouseMove
---------------------------------
on mouseUp
   put empty into lAllowDrag
end mouseUp
---------------------------------
on mouseRelease
   put empty into lAllowDrag
end mouseRelease
---------------------------------
on mouseLeave
   put empty into lAllowDrag
end mouseLeave

BTW I think you could put your image into a sub-stack without  
decorations (same dimensions as your image): this would allow to move  
the ruler all around the screen and not only in the current window :-)
More, let the image in your main stack and use a button in the sub-
stack the icon of which is the ID of your image: this would allow you  
to clone the sub-stack (if needed) and provide as many rulers you  
want on screen at the same time...

Le 9 juil. 05 à 16:22, Douglas Gilliland a écrit :

> I know it must be easy but I cannot figure out the script to make an
> image of a metric ruler draggable so my students can drag it around
> the screen to measure items in a quiz stack I am writing.
> Tried several variations of the following script:
> on mousedown
> make image "ruler.jpg" draggable
> end mousedown

Best Regards from Paris,

Eric Chatonet.
----------------------------------------------------------------
So Smart Software

For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch

Free plugins and tutorials on my website
----------------------------------------------------------------
Web site        http://www.sosmartsoftware.com/
Email        [hidden email]/
Phone        33 (0)1 43 31 77 62
Mobile        33 (0)6 20 74 50 86
----------------------------------------------------------------

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Making an image draggable

Bob Hartley
In reply to this post by Ken Ray
You wrote:

> > Tried several variations of the following script: on mousedown make
> > image "ruler.jpg" draggable end mousedown
>
> -- Script of ruler image on mouseDown
>   grab me
> end mouseDown
>
> Now this doesn't have any constraints, but it works very well...

Or only dragable when the control key is down

on mouseDown
    if the controlKey is down then
      grab me
      end if
end mouseDown

Cheers
Bob
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Making an image draggable

Derek Bump
In reply to this post by Douglas Gilliland
Douglas Gilliland wrote:
> I know it must be easy but I cannot figure out the script to make an
> image of a metric ruler draggable so my students can drag it around
> the screen to measure items in a quiz stack I am writing.

You could try the following...

1.  Create a separate stack.
2.  Place the "ruler.jpg" image on the stack.
3.  Resize the stack so it is the same dimensions as the image.
4.  Set the windowDecorations to empty
5.  Add the following to the stack's script...

local sgDragging
local sgOffset

on mouseDown
   put true into sgDragging
   put the mouseLoc into sgOffset
end mouseDown

on mouseMove
   if sgDragging then
     set the topLeft of this stack to \
     item 1 of the screenMouseLoc - item 1 of sgOffset, \
     item 2 of the screenMouseLoc - item 2 of sgOffset
   end if
end mouseMove

on mouseUp
   put false into sgDragging
end mouseUp

on mouseRelease
   put false into sgDragging
end mouseRelease


Derek Bump
Dreamscape Software
_______________________________________________
Compress Photos for the Web with JPEGCompress
http://www.dreamscapesoftware.com/
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Making an image draggable

Douglas Gilliland
Thanks to all - it's great to have this as a resource for learning transcript.
The following script works great.
on mouseDown
 grab me
end mouseDown
I will also try the others just to learn more about Revolution.
Thanks again.
Doug Gilliland
Sarasota, Fl
dodging the bullet with hurricane Dennis :>)

On 7/9/05, Derek Bump <[hidden email]> wrote:

> Douglas Gilliland wrote:
> > I know it must be easy but I cannot figure out the script to make an
> > image of a metric ruler draggable so my students can drag it around
> > the screen to measure items in a quiz stack I am writing.
>
> You could try the following...
>
> 1.  Create a separate stack.
> 2.  Place the "ruler.jpg" image on the stack.
> 3.  Resize the stack so it is the same dimensions as the image.
> 4.  Set the windowDecorations to empty
> 5.  Add the following to the stack's script...
>
> local sgDragging
> local sgOffset
>
> on mouseDown
>    put true into sgDragging
>    put the mouseLoc into sgOffset
> end mouseDown
>
> on mouseMove
>    if sgDragging then
>      set the topLeft of this stack to \
>      item 1 of the screenMouseLoc - item 1 of sgOffset, \
>      item 2 of the screenMouseLoc - item 2 of sgOffset
>    end if
> end mouseMove
>
> on mouseUp
>    put false into sgDragging
> end mouseUp
>
> on mouseRelease
>    put false into sgDragging
> end mouseRelease
>
>
> Derek Bump
> Dreamscape Software
> _______________________________________________
> Compress Photos for the Web with JPEGCompress
> http://www.dreamscapesoftware.com/
>
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution