Reputation: 153
Does anybody know how java counts clicks? and if so where that is documented? I know this is under the hood kind of stuff, but I would like to know what their definitions are.
I found the delay counter for multi click via Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval")
But, I cannot find what the pixel range is around which mouse movement is allowed and does not reset the counter. Any help would be appreciated.
EDIT:
I understand about MouseEvents. I do not need to GET this information from Java, I am curious how java decides whether or not there was a multi-click in the first place:
1)Timing is part (addressed above)
2)There is whether or not the mouse moves - how much leeway (in pixels) is given.
3)Potentially another quality that I cannot think of.
I am curious about points 2 & 3
Running Win 8
FURTHER EDIT: This got a little lost in the weeds. Ok, so the click itself is an event passed in via the OS. However, in the MouseEvent generated, there is a .getClickCount() function, which tells you how many clicks have occurred within the time interval specified by awt.multiClickInterval. There is however a small region around the point of one click that the mouse can move to and click again and still get counted (the mouse does not have to stay exactly on the same pixel). The question is: What is the maximum number of pixels away from one point that you can click and still have it get counted? This seems like it could not be an OS thing since the interval is an awt property.
Thank you.
Upvotes: 1
Views: 764
Reputation: 776
Events in Java are forwarded from the JVM. The JVM sits on top of an operating system that is forwarded system level events (eg: mouse clicks, key presses, signals, etc.), from the operating system, which are then forwarded to programs running on the JVM (such as a Java program) in an order of priority. Java does not usually make decisions about whether a system level event has occurred (at least not natively).
On ClickCount - this count also comes from the number of click events you receive. The IO reception is dependent on clock cycles. No human will be able to send an amount of IO that the computer can't keep up with. However, when I simulated the click amount with the computer - it stopped being able to measure, with complete accuracy, around 1 IO per 3-4 clock cycles. This is an obscene side case, though. My measurements are completely dependent on my hardware as well so you should take that into account.
The click count is identified by time difference, not pixel distance. I once read that this was distinguished as anything less than 500ms. However, there is no standardized time. The only thing I could find that agreed with me is WikiPedia.
Edit: Upon further investigation, there seems to be slight pixel reinforcement based on acceleration of the mouse and distance in pixels. This, however, is very hard to detect and isn't something that you need to rely on heavily. As long as you make a good attempt to double click in about the same place then you should be fine.
Upvotes: 1