Polling the mouse state

Geoff Canyon gcanyon at inspiredlogic.com
Thu Feb 21 01:27:01 EST 2002

At 4:37 AM +0000 2/21/02, Ian Summerfield wrote:
>Using the mousemove is no good.   I want to suspect all the messages from
>happening while I'm dragging a pin around on my timer plug.  With mousemove
>I'm effectively dropping back to an "idle" state between each call,  I need
>to stay in the handler,  to do that I'm back to checking myself whether the
>mouse is still down or not.
>Try this as an example,  call beeper from the message box to get the beeps
>going,  then the challenge is to make the drag work but suspect the beeps,
>however, just killing the event is no answer,  my program might have 30-40
>different events pending and killing them all is out of the question.

Why out of the question? It would be fairly simple to go through the list of pendingMessages and cancel them all. If you need to resend them later, keep the list to do that.

If you need to postpone the messages, as an alternative, you could modify each of the handlers that are called by inserting the following into each of them:

global dragging
if dragging then
  send (whateverThisHandlerIs) to me in howeverMany seconds
  exit to top
end if

That would make it automatic. But your best bet is to go through the pendingMessages.

>Put in card script,  and have a button called "drag":
>on mousedown
>  global dragging
>  put the short name of the target = "drag" into dragging
>end mousedown
>on mousemove x,y
>  global dragging
>  put x & "," & y into myPointIs
>  if xyz
>  then set the loc of the target to myPointIs
>   -- I have code here to check whether the object has intersected other
>   -- things, if so different drag handlers take over,  so using the
>   -- drag command  isn't on
>end mousemove
>on mouseup
>  global dragging
>  put false into dragging
>end mouseup
>on beeper
>  beep
>  send beeper to this card in 10 secs
>end beeper
>And all hell is let loose if a mouseup event is lost,  as can happen if you
>switch out of revolution with the mouse still down.

Try adding this handler:

on mouseRelease
  global dragging
  put false into dragging
end mouseRelease



More information about the Use-livecode mailing list