Click、DoubleClick 与 MouseClick 和 MouseDoubleClick 事件 [英] Click, DoubleClick vs MouseClick and MouseDoubleClick events

查看:81
本文介绍了Click、DoubleClick 与 MouseClick 和 MouseDoubleClick 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现 NotifyIcon 有 4 个类似名称的事件,名为 ClickDoubleClickMouseClickMouseDoubleClick.他们的描述文字说

<块引用>

在组件被(双击)[用鼠标]点击时发生.

但是除了鼠标,你还能点击什么元素?

我尝试用鼠标单击它并在使用箭头键和 Tab 键进行一些棘手的选择之后按 Enter.用鼠标点击会触发这两个事件,但按 Enter 只会触发 Click 事件.

这两对事件之间还有哪些其他区别?

解决方案

假设您指的是 WinForm 控件事件,来自 Control.Click:

<块引用>

点击不仅可以由鼠标点击引起,还可以由一些事件引起如按下的键等

Click 事件将一个 EventArgs 传递给其事件处理程序,因此它仅指示发生了单击.如果您需要更具体的鼠标信息(按钮、点击次数、滚轮旋转或位置),请使用 MouseClick 事件.但是,如果单击是由鼠标以外的操作(例如按下 ENTER 键)引起的,则不会引发 MouseClick 事件.

  • 点击事件

Click 事件将一个 EventArgs 传递给其事件处理程序,因此它仅指示发生了单击.如果您需要更具体的鼠标信息(按钮、点击次数、滚轮旋转或位置),请使用 MouseClick 事件.但是,如果单击是由鼠标以外的操作(例如按下 ENTER 键)引起的,则不会引发 MouseClick 事件.

  • 鼠标点击事件

当光标悬停在控件上时按下鼠标按钮通常会从控件引发以下一系列事件:

  1. MouseDown 事件.
  2. 点击事件.
  3. 鼠标点击事件.
  4. MouseUp 事件.

来源

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?

解决方案

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

这篇关于Click、DoubleClick 与 MouseClick 和 MouseDoubleClick 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆