locked
Remove the delay in handling click events? RRS feed

  • Question

  • Hey all.

    I am building a windows form, I have added a picture box to the form and it needs to deal with click events. I am only interested in single clicks, double clicks should really just be processed as 2 click events. There seems to be a delay between the click events of about 0.3 - 0.4 seconds if you click them very quickly. 

    Is there anything that can be done to remove this delay, as I need to be able to handle fast clicks as well.

    Thank.


    Developer
    Monday, June 28, 2010 8:56 AM

Answers

  • Changing the double click time will aggravate the user.  Use MouseDown or MouseUp events.
    • Marked as answer by Helen Zhou Monday, July 5, 2010 7:25 AM
    Monday, June 28, 2010 10:13 AM
  • Hello! The mousedown/up events contain a Clicks property which gives you the # of clicks performed..

    A simple Switch-Case / If statements can help define your single,double,left,middle,right clicks..

     

        private void mButton1_MouseDown(object sender, MouseEventArgs e)
        {
          if (e.Clicks == 1 && e.Button == System.Windows.Forms.MouseButtons.Left) ; //Single left click
          if (e.Clicks == 2 && e.Button == System.Windows.Forms.MouseButtons.Left) ; //Double left click
        }
    • Marked as answer by Helen Zhou Monday, July 5, 2010 3:01 AM
    Monday, June 28, 2010 2:18 PM

All replies

  • Changing the double click time will aggravate the user.  Use MouseDown or MouseUp events.
    • Marked as answer by Helen Zhou Monday, July 5, 2010 7:25 AM
    Monday, June 28, 2010 10:13 AM
  • so does that mean it is the double click event that is holding up my single clicks then? If so, then I'll try the mouse up like you suggest.

    Thanks.


    Developer
    Monday, June 28, 2010 10:22 AM
  • Hello! The mousedown/up events contain a Clicks property which gives you the # of clicks performed..

    A simple Switch-Case / If statements can help define your single,double,left,middle,right clicks..

     

        private void mButton1_MouseDown(object sender, MouseEventArgs e)
        {
          if (e.Clicks == 1 && e.Button == System.Windows.Forms.MouseButtons.Left) ; //Single left click
          if (e.Clicks == 2 && e.Button == System.Windows.Forms.MouseButtons.Left) ; //Double left click
        }
    • Marked as answer by Helen Zhou Monday, July 5, 2010 3:01 AM
    Monday, June 28, 2010 2:18 PM
  • Hi eyeballpaul,

    Said on msdn "The Click event passes an EventArgs to its event handler, so it only indicates that a click has occurred. If you need more specific mouse information (button, number of clicks, wheel rotation, or location), use the MouseDown and MouseUp events which pass a MouseEventArgs to the event handler.

    A double-click is determined by the mouse settings of the user's operating system. The user can set the time between clicks of a mouse button that should be considered a double-click rather than two clicks. The Click event is raised every time a control is double-clicked. For example, if you have two event handlers for the Click and DoubleClick events of a Form, the Click and DoubleClick events are raised when the form is double-clicked and both methods are called. If an item is double-clicked that does not support the DoubleClick event, the Click event might be raised twice."

    Hope it helpful to you.

    Sincerely,
    Helen Zhou


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Tuesday, July 6, 2010 7:47 AM