Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I searched MSDN for e.ClickCount, and it provieds the following eg.:
HTML
<textblock x:name="tb" text="" background="Black" foreground="White" />

and the code behind:
C#
public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

           this.tb.MouseDown += new MouseButtonEventHandler(tb_MouseDown);
        }

       void tb_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // Checks the number of clicks.
           if (e.ClickCount == 1)
            {
                // Single Click occurred.
                this.tb.Text = "Single Click";

               DoSomethingForClick();

           }
            if (e.ClickCount == 2)
            {
                // Double Click occurred.
                this.tb.Text += "Double Click";

              DoAnotherForDoubleClick();

            }
            if (e.ClickCount >= 3)
            {
                // Triple Click occurred.
                this.tb.Text += "Triple Click";
            }

       }
    }


But what I want to get is like this:

(1)When I click once at one time, then execute DoSomethingForClick(). This has no problem!

(2)When I click twice at one time, then only execute DoAnotherForDoubleClick(). NOT firstly execute DoSomethingForClick() and then execute DoAnotherForDoubleClick() like in the MSDN eg., because tb_MouseDown fired 2 times;

How can I do?
Posted
Updated 25-Sep-12 23:30pm
v4
Comments
Sergey Alexandrovich Kryukov 25-Sep-12 21:23pm    
I'm sure you can do it, but why? Imagine the confusion of the user. Can you always distinguish it by yourself what it was: two separate clicks or a double click? I would rather review the conception of your UI and usability.
--SA

1 solution

I think your problem is caused by the system sending the following stream of messages for each 'double click' (check 'WM_LBUTTONDBLCLK' on msdn).

WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCLK -- Second WM_LBUTTONDOWN replaced
WM_LBUTTONUP
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900