![]() |
|
Do Loop, Sleep and Mouse Button - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Do Loop, Sleep and Mouse Button (/showthread.php?tid=3909) |
Do Loop, Sleep and Mouse Button - Dimster - 09-05-2025 I have code laid out as follows: Do Do ...some code Loop Sleep Do ....some more code Loop Sleep Loop Until _MouseButton(1) What happens with this code is that I can loop between two screens of data results ad infinitum and linger on the screens as long as I like before triggering the 2nd screen. The plan was to exit using a Left Button click alone, but what's happening is that I need to hold down any key and then the Left Button click. That holding down any key has the screens rapidly flipping until the Left Button click. I believe I need a different mechanism than "Sleep" to allow each Screen of data to display as long as the user likes before presenting the next screen of data. I don't think _Delay or _Limit would work here??? RE: Do Loop, Sleep and Mouse Button - bplus - 09-05-2025 What gets you out of the 2 inner loops? Does "some code" and "some more code" have an Exit Do condition? How bout 'data screen sleep 'data screen sleep . . . 'end RE: Do Loop, Sleep and Mouse Button - Pete - 09-05-2025 Code: (Select All)
Keep in mind with this structure you still need to press "any key" after pressing a 1 or 2 to switch screens, but when the prompt is visible, a left mouse click will exit the outer wend loop. Also note that if you press 1 and don't press "any key" the mouse is no longer enabled as coded. You are in a dead zone until "any key" is pressed as SLEEP doesn't poll the mouse. Pete RE: Do Loop, Sleep and Mouse Button - SMcNeill - 09-05-2025 Code: (Select All)
My solution to this type little problem. See if it makes sense to you and if it's simple enough to understand. ![]() Instead of your SLEEP statement, I swapped in a simple little pause routine that reports if the mouse was clicked or if a key was pressed. On a key press, it simply moves on to the next loop. On a mouseclick (-1), it exits the loop. It's that easy of a process. RE: Do Loop, Sleep and Mouse Button - Pete - 09-05-2025 That's a nice example, basically what my routines do but without using a full keyboard and mouse library. Honestly, Dim, if you don't mind studying the code a bit, in the long run abandoning SLEEP and replacing it with Steve's routine will pay dividends far into the future. Pete RE: Do Loop, Sleep and Mouse Button - Dimster - 09-06-2025 A Pause Function - cool. Perhaps we should add _Pause to our lexicon of QB64PE syntax. Thanks for that suggestion Steve bplus, each of the inner Do Loops are drawing data from two different files, so the Do is actually Do While Not EOF(x) Pete, I did have something similar using Inkey$ but I detected the MouseButton at the end of the main outer loop so things didn't go well. As mentioned the MouseButton didn't seem to be recognized. I should have had the Inkey$ and MouseButton work in tandem as you suggested. Not sure why I didn't think of that...too many beers. I very much appreciate the help. |