Determining left or right movement in a mouseMove handler

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Determining left or right movement in a mouseMove handler

Richmond Mathewson via use-livecode
Hi there

How can I determine if the mouse is moving left or right (or up or down) on the screen in a mouseMove handler?

Not just from the outset (that is easy) but at any moment, like when a user changes his mind and move the opposite way.

Something like put x into oldX will not work.

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

Re: Determining left or right movement in a mouseMove handler

Richmond Mathewson via use-livecode
You do need to track the last location... here is a stack that does what
you want.  (script could be better i'm sure, but its a starting point..  )
https://www.dropbox.com/s/y6du5nmz5diiv0f/movedir.livecode?dl=0

Basically I put 4 square graphics on screen, top, bottom, right, and left
position.

Then used the following script..

local smX,smY

on mousemove x,y
--####If the mouse hasn't moved yet, do the initial fill of the 2 script
local variables smX and smY
if smx is empty then put x into smx
if smy is empty then put y into smy

-- Compare the last x position to the current x position and color grc
accordingly
if smx > x then
set the backcolor of grc "ltG" to blue
set the backcolor of grc "rtg" to empty
else if smx < x then
set the backcolor of grc "ltG" to empty
set the backcolor of grc "rtg" to blue
end if

-- same thing for y
if smy > y then
set the backcolor of grc "upG" to blue
set the backcolor of grc "dng" to empty
else if smy < y then
set the backcolor of grc "upG" to empty
set the backcolor of grc "dng" to blue
end if

put x into smx
put y into smy
end mousemove

On Tue, Jun 27, 2017 at 4:32 AM, Michael Kristensen via use-livecode <
[hidden email]> wrote:

> Hi there
>
> How can I determine if the mouse is moving left or right (or up or down)
> on the screen in a mouseMove handler?
>
> Not just from the outset (that is easy) but at any moment, like when a
> user changes his mind and move the opposite way.
>
> Something like put x into oldX will not work.
>
> Thanks
> Michael
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Determining left or right movement in a mouseMove handler

Richmond Mathewson via use-livecode
In reply to this post by Richmond Mathewson via use-livecode
Hoping I didn't mix up the x's and y's, I believe the script you need
looks like this:

local myOldX,myOldY
on mouseMove theNewX,theNewY
   if myOldX < theNewX then put
     "right" into myMovement
   else
     put "left" into myMoveMent
   end if
   if myOldY > myNewY then put
     "down" into myMoveMent
   else
     put "up" into myMoveMent
   end if
   // do something with right, left,
   // up and down here.
   put theNewX into myOldX
   put theNewY into myOldY
   pass mouseMove
end mouseMove


Kind regards,

Mark Schonewille
http://economy-x-talk.com
https://www.facebook.com/marksch

Buy the most extensive book on the
LiveCode language:
http://livecodebeginner.economy-x-talk.com

Op 27-Jun-17 om 12:32 schreef Michael Kristensen via use-livecode:

> Hi there
>
> How can I determine if the mouse is moving left or right (or up or down) on the screen in a mouseMove handler?
>
> Not just from the outset (that is easy) but at any moment, like when a user changes his mind and move the opposite way.
>
> Something like put x into oldX will not work.
>
> Thanks
> Michael
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Loading...