Click, DoubleClick vs MouseClick and MouseDoubleClick events

一笑奈何 提交于 2020-01-14 14:12:50

问题


I just found out that there are 4 similarly names events for NotifyIcon named Click, DoubleClick, MouseClick and MouseDoubleClick. The description text for them says

Occurs when the component is (double-)clicked [with mouse].

But what else can you click elements with except mouse?

I tried clicking it with mouse and pressing Enter after some tricky selection stuff with arrow keys and tabbing. Clicking with mouse fires both events, but pressing Enter only fires the Click event.

What other differences are between these two pairs of events?


回答1:


Assuming you're referring to WinForm Control events, from the MSDN documentation for Control.Click:

A click can be caused by not only a mouse click, but also some events like a pressed key, etc.

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 MouseClick event. However, the MouseClick event will not be raised if the click is caused by action other than that of the mouse, such as pressing the ENTER key.

  • Click Event

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 MouseClick event. However, the MouseClick event will not be raised if the click is caused by action other than that of the mouse, such as pressing the ENTER key.

  • Mouse Click Event

Depressing a mouse button when the cursor is over a control typically raises the following series of events from the control:

  1. MouseDown event.
  2. Click event.
  3. MouseClick event.
  4. MouseUp event.

Source



来源:https://stackoverflow.com/questions/21670126/click-doubleclick-vs-mouseclick-and-mousedoubleclick-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!