Alejandro Tejada wrote:
on Sat, 10 Sep 2005 Richard Gaskin wrote:


I'm making a specialized drawing tool, and I need to
know when the mouse is clicked outside of any control while the pointer
tool is active


A frontscript could do what you want,

A frontscript can only respond to messages that exist. In this case, the issue is that mouseDowns and mouseUps that occur on the card outside of any objects are not sent when the pointer tool is active.

Well, actually the mouseDown and mouseUp ARE sent, but only when button 3 on the mouse is pressed; the messages aren't sent for button 1.

While we wait for mousedown and mouseup to become more orthogonal, or alternatively to the implementation of SuperCard's pointerDown and pointerUp messages, thus far the best workaround for the missing messages is a polling solution.

Polling is normally something I avoid unless absolutely necessary, as it's ususally much less efficient that getting a message: messages come from the engine's event loop, while polling is effectively running your own scripted event loop on top of that. Moreoever, with polling solutions most of the time whatever you're checking isn't what you need, waiting for the one time out of thousands that you do.

For example, in this case we could use a timer sent to itself repeatedly which monitors if the mouseclick is true, and if so whether there is no target control. If both conditions are true when can send ourselves a message to do what we need in lieu of getting a mouseUp.

One problem with timers is that they eat up a lot of processor time. Testing on 1/10th-second increments (100 millisecs) brought the idle processing for my app to almost 30%. Bringing that down to a quarter-second (250 milliseconds) interval reduced it to about 10-15%, still more than I'd care for something this trivial.

Thinking outside the box, Ken suggested looking into mouseMove, checking if the mouse is down. That option turns out to consume far less processor time, and for the moment is the one I'm going with.

But the day we get a true message for this I'll be ever so happy to back out that code. :)

--
 Richard Gaskin
 Managing Editor, revJournal
 _______________________________________________________
 Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to