Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Repeating mouse check
#2
The issue is your `While _MouseButton(1): Wend`, it needs a `m% = _MouseInput` inside to keep it from being an infinite loop. (Ideally also a `_Limit` to avoid high CPU usage).

The way to think of the mouse handling is that every change to the mouse state (button press/release, position change, etc.) has to go to the back of a queue line and wait, they don't get immediately shown to the program. All the functions like `_MouseButton(x)`, `_MouseX`, `_MouseY`, etc. only show you the state that is currently first in the queue line. Unless you advance the queue line to the next state that is waiting, those function will continue to return the same values regardless of what the user does with the mouse (since any mouse changes simply add more entries to the back of the queue line, they don't change what is currently first)

Calling `_MouseInput` is how you advance the queue line to the next state, when it gets called those functions I mentioned (`_MouseButton(x)`, etc.) will start showing whatever the next event in the queue line is (or the same values, if there was nothing else in the queue line at the time). The return value of `_MouseInput` tells you whether anything was in the queue (so if it returns zero, there were no new changes to process).

The purpose of this system is so that you can't miss mouse events, regardless of how slow you check for them. If the user clicks really quickly or moves really quickly your program does not need to be checking the mouse hundreds of times a second to ensure you don't miss it. Rather, you can't miss the mouse event because the actual state changes are just put into the queue line, you'll eventually see them when processing through the queue using `_MouseInput` at whatever speed you want.
Reply


Messages In This Thread
Repeating mouse check - by PhilOfPerth - 07-24-2024, 03:50 AM
RE: Repeating mouse check - by DSMan195276 - 07-24-2024, 05:03 AM
RE: Repeating mouse check - by PhilOfPerth - 07-24-2024, 05:47 AM
RE: Repeating mouse check - by Pete - 07-24-2024, 09:08 PM
RE: Repeating mouse check - by PhilOfPerth - 07-24-2024, 11:26 PM



Users browsing this thread: 2 Guest(s)