Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the Java doClick() use 68 milliseconds when it calls doClick(pressTime)?

In doClick() when it calls doClick(pressTime) does it send 68 milliseconds? Why did they decide on 68 instead of a more round number? Is it a completely arbitrary number?

From Java AbstractButton:

public void doClick() {
    doClick(68);
}
like image 910
Ian Avatar asked Jun 15 '16 15:06

Ian


1 Answers

It might have to do with how fast a human can click on average.

If you look at this timer, with a bit of excersise it's possible to reach the 68ms on average.

They might have simply made a setup like below, had a go at it to get on a nice average click duration and then used that for the default value.

var timer = 0;
var results = [];
$('#clicktest').on('mousedown',function() {
    timer = window.performance.now();
});
$('#clicktest').on('mouseup',function() {
    results.push(window.performance.now()-timer);
    var total = 0;
    for(c=0;c<results.length;c++) {
        total+= results[c];
    }
    $('#output').text('Average click duration '+ Math.round(total/results.length)+'ms');
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="clicktest">Click me</button>
<div id="output">Average click duration N/A</div>
like image 178
Tschallacka Avatar answered Jan 29 '23 18:01

Tschallacka