We are about to switch to a new forum software. Until then we have removed the registration on this forum.
If I click on mouse button and it starts doing process.
If i click while it is doing something , when it is done it automatically does it again because mouse pressed is true again i assume because of the stored mouse click button pressed variable
Is there some way to clear the mouse button or set mouse pressed to false by force after each
Answers
@jeffmarc -- Please provide a short example code here to show the specific problem that you are having.
It sounds like you are using mousePressed() -- which fires every frame (~60 times a second) while the mouse is being pressed. Instead, try using mouseClicked() -- which fires once when the mouse button is released and does not fire again until the mouse is pressed and then released again.
tryed both, it acts like it is storing mouse clicks to be processed in a que. When the program is done with the process in draw() it pick up the next button click and does it again! without me touching anything.
this only happens if i click the mouse button more than once during the scanning Pressing the mouse starts a scan from a flatbed scanner. the program waits until is is done and the file appears in the directory than continues.
@jeffmarc --
I see -- I incorrectly guessed your problem was with the default fps 60 because you didn't provide any information on how the problem arises. Providing a short example code to show your specific problem is best when you need help.
You are correct -- each click is queued and then the queue is processed between draw() calls. If there is a long gap between draw calls and you click, clicks will be queued.
If you want to ignore the mouse clicks during a particular program state, just turn that mouse code off with a conditional flag -- then turn the code back on when the program resumes.
Here is an example that throws away click events while
waiting
is true:This code can also be modified to check if any clicks happened when it resumes and then produce a single click rather than many.
There may be other ways of manipulating the event queue at a lower level, but this should be a simple and flexible way of accomplishing what you want.
https://forum.Processing.org/two/discussion/19203/function-which-permits-leave-from-loop#Item_7
https://forum.Processing.org/two/discussion/18517/timing-for-draw-loop#Item_7