dragging a line gets dashed

J. Landman Gay jacque at hyperactivesw.com
Fri Oct 11 14:15:32 EDT 2013


On 10/11/13 8:20 AM, Tiemo Hollmann TB wrote:
> Hello,
>
> LC 6.1, Win7, I have the following handler to let the user drag a line:
>
>     lock messages
>
>     repeat while the mouse is down
>
>        wait with messages
>
>        drag from tOldLoc to the mouseLoc
>
>        put the mouseLoc into tOldLoc
>
>     end repeat
>
>     unlock messages
>
> dragging the mouse the line gets drawn fine, if I move the mouse slowly.
> When moving the mouse faster, the line gets dashed/dotted. So obviously the
> repeat loop can't take off the mouse movement. I tried with/without lock
> messages and with/without waiting, but the result is always almost the same.
> Obviosly the repeat loop also depends on the processor cylcle, but my
> computer isn't that old and I think pretty representative for the average of
> my clients.
>
> Any idea, how to speed up the drawing process, so that the line doesn't get
> dashed?

It works okay for me, but I have a newer Mac with a fast processor. I 
can only make some guesses:

The "wait" command has no time specified. It shouldn't matter too much, 
but it isn't correct syntax so the engine might be doing something odd.

On a slower computer, there might be enough processing time required 
that the mouseloc in the first line isn't the same as the second line. 
You can solve that by storing the mouseloc before you work with it, to 
make sure it hasn't changed:

  wait 1 millisecond with messages
  put the mouseloc into tCurLoc
  drag from tOldLoc to the tCurLoc
  put tCurLoc into tOldLoc

Finally, repeat loops are slow and inefficient, and polling the state of 
the mouse is also inefficient. This repeat loop polls the mouse twice in 
each repeat. It would be better written as a mousemove handler. 
MouseMove is fast, it provides the current mouseloc in its parameters so 
you don't need to poll, and isn't a repeat loop. If you need help with 
that, just ask.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list