Forbid Double MouseClick

Hello,



if I register an ActionListener and overwrite the onAction method, is there an easy way to trigger double moueclicks or do I have to take the tps value and calculate that a special amount of time has elapsed before allowing the action to react again?



Thanks,

Equi

No there is no double click support in JME3 input system, but your way around this sounds good.

The way you would do it is you store the time since the user last clicked, when he clicks again, check that time vs. the current time and if its below a certain threshold, the user double-clicked.

It seems with that approach that if the user were to click three times successively within the threshold, then it would register as two double clicks. I am not sure if you would want it to respond like that, so you might need to modify it so that once a double click has occurred, you reset the time since last click variable to some default value so that it doesn’t immediately register another double click. This is just a thought, I hope it helps.

Momoko_Fan said:
The way you would do it is you store the time since the user last clicked, when he clicks again, check that time vs. the current time and if its below a certain threshold, the user double-clicked.


This is actually the way to prevent 'double taps' on iOS. The key is finding the right value for the threshold, which highly depends on the type of game your building.