mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
MouseSettings: Reset the double-click timer after every second click
The old behavior of restarting the timer after every second click could result in double-click-chains (or triple+ clicks), which does not feel like the right behavior. By resetting the double-clicking timer, you need to perform a new full double-click to make the arrows change color again.
This commit is contained in:
parent
7c939c58b8
commit
770c1935d4
1 changed files with 8 additions and 9 deletions
|
@ -55,20 +55,19 @@ void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
void DoubleClickArrowWidget::mousedown_event(GUI::MouseEvent&)
|
||||
{
|
||||
if (!m_double_click_timer.is_valid()) {
|
||||
auto double_click_in_progress = m_double_click_timer.is_valid();
|
||||
auto elapsed_ms = double_click_in_progress ? m_double_click_timer.elapsed() : 0;
|
||||
|
||||
if (!double_click_in_progress || elapsed_ms > m_double_click_speed) {
|
||||
m_double_click_timer.start();
|
||||
return;
|
||||
}
|
||||
|
||||
auto elapsed_time = m_double_click_timer.elapsed();
|
||||
if (elapsed_time <= m_double_click_speed) {
|
||||
dbgln("Double-click in {}ms", elapsed_time);
|
||||
dbgln("Double-click in {}ms", elapsed_ms);
|
||||
m_inverted = !m_inverted;
|
||||
update();
|
||||
}
|
||||
|
||||
// Reset the timer after each click
|
||||
m_double_click_timer.start();
|
||||
m_double_click_timer.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue