Looking at the MSDN documentation, it is not quite clear to me when a click event is raised. What is the order? is it:
mousedown, mouseup, click?
Thanks
Looking at the MSDN documentation, it is not quite clear to me when a click event is raised. What is the order? is it:
mousedown, mouseup, click?
Thanks
This is for winforms, more information here: Mouse Events in Windows Forms
The very definition of 'click' incorporates the mousedown and mouseup movement. You can demonstrate this by having a simply button on your form and display a Messagebox when it's clicked. The messagebox only shows after the mouse button has been released.
If you are talking about ASP.NET it is raised after the postback.
<asp:Button ID="But" runat="server" />
You will handle the event after the postback.
protected void Page_Load(object sender, EventArgs e)
{
But.Click += (s, ev) =>
{
// after the postback
// the method Page_Load will be called again
// re-bind the event
// and just after it this event will be called
};
}
Looking on MSDN some more I found this page: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mouseclick.aspx
Which gives the pertinent info:
Depressing a mouse button when the cursor is over a control typically raises the following series of events from the control:
MouseDown event.
Click event.
MouseClick event.
MouseUp event.
Mouse Down: Mouse down on a control
Mouse Up: When you release the mouse raises on the control where you mouse up
Click: A mouse down followed by a mouse up both on the same control
Double Click: two clicks on the same control with less than a defined period of time (this time can be set in operating system settings)
Contrary to its name, a Click
event may not be associated with mouse activity at all.
For example, if you set the ToolStripMenuItem.ShortcutKeys property, then the Click
event for that menu item will fire whenever the shortcut key (combination) is pressed.
Another example is "clicking" a button by hitting enter.