#660 – Changing the Double-Click Speed in Windows 8

When you double-click on a user interface element, Windows gives you a certain amount of time between the two clicks that make up the double-click.  If you wait too long before clicking the mouse a second time, your clicks are treated as two single clicks, rather than one double-click.

You can change the amount of time you’re given between the clicks as follows.

Click on the Windows key to bring up the Start Screen.  Type in mouse and then click on Settings.

Click on Change mouse click settings.

The Mouse Properties window will come up.  On the Buttons tab, you can change the time allowed for double-clicks using the slider in the Double-click speed section.

Changing the setting to become more Slow means that you can wait longer before the second half of the double-click.  (Up to 900 milliseconds).  Fast means that you have less time (as little as 200 milliseconds).

#659 – Detecting a Triple Click

Although not very common in user interfaces, you can use the MouseButtonEventArgs.ClickCount property, available in the PreviewMouseDown or MouseDown events, to detect a triple click.  (You can also detect right vs. left mouse button clicks using the button specific events, e.g. MouseLeftButtonDown and MouseRightButtonDown).

In the example below, double clicking on the Label does nothing.  But a triple click, with either button, toggles the background color of the label.

    <StackPanel Margin="20" >
        <Label Content="Triple-click on me" Margin="20"
               MouseDown="Label_MouseDown" />
    </StackPanel>

In the event handler, we check ClickCount and change the Background of the Label if it’s equal to 3 (a triple click).

        private bool colorToggled = false;

        private void Label_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 3)
            {
                if (!colorToggled)
                {
                    ((Label)sender).Background = Brushes.Blue;
                    colorToggled = true;
                }
                else
                {
                    colorToggled = false;
                    ((Label)sender).Background = null;
                }
            }
        }


#658 – An Easier Way to Handle Mouse Double Clicks

You can detect mouse double clicks on user interface elements by handling one of the the mouse button events (e.g. MouseDown) on the element and checking to see if the MouseButtonEventArgs.ClickCount property has a value of 2.  The various mouse button events are defined for anything that derives from UIElement or ContentElement.

If your user interface element derives from Control, you can instead just handle the MouseDoubleClick (or PreviewMouseDoubleClick) event.

The sequence of events that fire when the user double-clicks a control with the left mouse button is shown below.  (For simplicity, I’m omitting the MouseLeftButtonDown and MouseLeftButtonUp events and their associated preview events.

  • PreviewMouseDown, with ClickCount = 1
  • MouseDown, with ClickCount = 1
  • PreviewMouseUp
  • MouseUp
  • PreviewMouseDoubleClick
  • PreviewMouseDown, with ClickCount = 2
  • MouseDoubleClick
  • MouseDown, with ClickCount = 2
  • PreviewMouseUp
  • MouseUp

The MouseDoubleClick event does send an instance of MouseButtonEventArgs, but its ClickCount property will always be equal to 1.