jspencer78 at mac.com
Wed Mar 16 18:07:28 CST 2005
On Mar 16, 2005, at 12:40 PM, J. Landman Gay wrote:
> On 3/15/05 9:16 PM, James Spencer wrote:
>> I've got a button which, when it is pressed and held, I want to do
>> some things (brief and repetitive) and then do some other things once
>> it is released. I've got handlers in the button script:
>> on mouseDown
>> repeat while the mouse is down
>> -- do stuff repeatedly while mouse is down
>> end repeat
>> -- do some quick cleanup code before exiting
>> end mouseDown
>> on mouseUp
>> -- do stuff now that the button as been released
>> end mouseUp
>> My mouseUp handler is not being called. Well that's not really true;
>> it has been called exactly once in maybe a couple of dozen trials.
> This all used to work the same as it does in HyperCard back in the
> Beginning Of MC Time, but the behavior changed a few years ago.
> Tracking mouseup within a loop was CPU-intensive and Scott Raney
> wanted to change the behavior to make MetaCard more efficient. There
> was some discussion on the mailing list about it (and about how it
> would break legacy stacks,) but eventually it was decided that mouseup
> would no longer be cached in the event queue; instead it would only be
> sent if the mouse were actually going up at exactly the moment the
> script encountered the test command.
> The HC-style loop polling is strongly discouraged in MC/Revolution. It
> was sort of okay to do in OS 9 because there wasn't really any
> multi-tasking, but with modern OS architecture, polling the mouse can
> bring some systems to their knees if the loop goes on long enough.
> So what you need to do instead, which is much more efficient and
> friendly, is this:
> I think it was Chipp who posted a briefer response with the same
> technique, but this web page may give you some additional ideas.
Thank you (and Chipp and PL) for the answer to the question which was
more of a matter of curiosity than anything else. I had planned to
change this to not use polling anyway but was fiddling and couldn't
make this work and was simply wondering why. Interestingly, Dan
Shafer, while being clear about the downside of using the polling
functions (and citing your article Jacque), actually has code almost
identical to mine in his laboratory exercise on page 129 asserting tht
"this approach would work fine."
James P. Spencer
jspencer78 at charter.net
"Badges?? We don't need no stinkin badges!"
More information about the use-livecode