Re: mouseDown/mouseUp problem
Hi James, For various reasons, it's not a good idea to use the 'repeat while the mouse is down' or even 'mouseStillDown' (check the archives as there's a lot of info on it) I think you're better doing something like: local lMouseIsDown on mouseDown put true into lMouseIsDown send doRepeat to me in 30 milliseconds end mouseDown on doRepeat if lMouseIsDown then --DO STUFF HERE send doRepeat to me in 30 milliseconds end if end doRepeat on mouseUp mouseRelease end mouseUp on mouseRelease put false into lMouseIsDown -- DO MOUSE IS UP STUFF end mouseRelease 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 ___ use-revolution mailing list use-revolution@lists.runrev.com http://lists.runrev.com/mailman/listinfo/use-revolution
Re: mouseDown/mouseUp problem
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: http://www.hyperactivesw.com/polling.html I think it was Chipp who posted a briefer response with the same technique, but this web page may give you some additional ideas. -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com http://lists.runrev.com/mailman/listinfo/use-revolution
Re: mouseDown/mouseUp problem
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: http://www.hyperactivesw.com/polling.html 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. Spence James P. Spencer Rochester, MN [EMAIL PROTECTED] Badges?? We don't need no stinkin badges! ___ use-revolution mailing list use-revolution@lists.runrev.com http://lists.runrev.com/mailman/listinfo/use-revolution
Re: mouseDown/mouseUp problem
On 3/16/05 6:07 PM, James Spencer wrote: 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. Lynch him! I'll get the rope. :) -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com http://lists.runrev.com/mailman/listinfo/use-revolution
Re: mouseDown/mouseUp problem
You'll have to catch me first. I'm slow but I'm sneaky. Seriously Yeah, I realize that -- and probably a few other things -- got through my first HC-to-Rev filtering process. I've marked that Laboratory for deletion in the next revisions of the book. dan (whose neck seriously does not need stretching!) On Mar 16, 2005, at 4:20 PM, J. Landman Gay wrote: On 3/16/05 6:07 PM, James Spencer wrote: 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. Lynch him! I'll get the rope. :) -- Jacqueline Landman Gay | [EMAIL PROTECTED] HyperActive Software | http://www.hyperactivesw.com ___ use-revolution mailing list use-revolution@lists.runrev.com http://lists.runrev.com/mailman/listinfo/use-revolution ___ use-revolution mailing list use-revolution@lists.runrev.com http://lists.runrev.com/mailman/listinfo/use-revolution
mouseDown/mouseUp problem
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. I haven't been able to repeat this and I have no idea what was different the one time that the mouseUp message was sent. To mention the obvious, the message watcher shows me that the mouseUp message simply isn't being sent. I assume I am running into some well-documented process where my repeat in the mouseDown handler eats the mouseUp but I'm not seeing it. Can someone give me some guidance? For what it is worth this is under Mac OS X 10.3.8 James P. Spencer Rochester, MN [EMAIL PROTECTED] Badges?? We don't need no stinkin badges! ___ use-revolution mailing list use-revolution@lists.runrev.com http://lists.runrev.com/mailman/listinfo/use-revolution
Re: mouseDown/mouseUp problem
JS, It could be something in your cleanup code. But I'd try a mouseStillDown handler to see if that gets better results. PL ___ use-revolution mailing list use-revolution@lists.runrev.com http://lists.runrev.com/mailman/listinfo/use-revolution