[TIDBIT] Group grab and drag

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

[TIDBIT] Group grab and drag

FlexibleLearning
A tidbit for your Scripter's Scrapbook:
- How to use the mouse to grab and drag a scrolling group
(see also the 'Grab' command in the Transcript dictionary to grab and  drag
an object)

Put this in the script of your scrolling group...
 
-----
local GrabMe,xOff,yOff

on mouseDown
put "true" into  GrabMe
put item 1 of the mouseLoc into xOff
put item 2 of  the mouseLoc into yOff
end mouseDown

on mouseMove x,y
if  GrabMe then
if the mouse is "up"  then
put "false" into  GrabMe
exit mouseMove
end if
set the hScroll of me to (the hScroll of me + xOff  - x)
set the vScroll of me to (the vScroll of me + yOff -  y)
put x into xoff
put y into  yoff
end if
end mouseMove
-----


/H
The Scripter's  Scrapbook
www.FlexibleLearning.com/ssbk.htm
 
_______________________________________________
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: [TIDBIT] Group grab and drag

Chipp Walters
Hugh,

Does it make more sense to add:

on mouseUp
   if GrabMe is true then set GrabMe to false
   pass mouseUp
end if

on mouseRelease
   mouseUp
   pass mouseRelease
end mouseRelease

rather than checking for the mouseUp state in the mouseMove handler?
That way you are 'constantly polling' mouseUp.

Just my 2 cents...

best,

Chipp

[hidden email] wrote:

> A tidbit for your Scripter's Scrapbook:
> - How to use the mouse to grab and drag a scrolling group
> (see also the 'Grab' command in the Transcript dictionary to grab and  drag
> an object)
>
> Put this in the script of your scrolling group...
>  
> -----
> local GrabMe,xOff,yOff
>
> on mouseDown
> put "true" into  GrabMe
> put item 1 of the mouseLoc into xOff
> put item 2 of  the mouseLoc into yOff
> end mouseDown
>
> on mouseMove x,y
> if  GrabMe then
> if the mouse is "up"  then
> put "false" into  GrabMe
> exit mouseMove
> end if
> set the hScroll of me to (the hScroll of me + xOff  - x)
> set the vScroll of me to (the vScroll of me + yOff -  y)
> put x into xoff
> put y into  yoff
> end if
> end mouseMove
_______________________________________________
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