MouseEventArgs 类

定义

为与鼠标相关且并不具体涉及鼠标按钮或鼠标滚轮的路由事件(如 MouseMove)提供数据。Provides data for mouse related routed events that do not specifically involve mouse buttons or the mouse wheel, for example MouseMove.

public ref class MouseEventArgs : System::Windows::Input::InputEventArgs
public class MouseEventArgs : System.Windows.Input.InputEventArgs
type MouseEventArgs = class
    inherit InputEventArgs
Public Class MouseEventArgs
Inherits InputEventArgs
继承
派生

注解

此事件数据类与以下附加事件一起使用。This event data class is used with the following attached events.

此事件数据类与以下路由事件一起使用。This event data class is used with the following routed events. 这些路由事件转发前面列出的附加事件,使其在 WPFWPF 中的常规元素模型中更易于访问。These routed events forward the previously listed attached events to make them more accessible to the general element model in WPFWPF.

附加事件和基本元素路由事件共享其事件数据,路由事件的冒泡和隧道版本也共享事件数据。The attached events and the base element routed events share their event data, and the bubbling and tunneling versions of the routed events also share event data. 这可能会影响事件在传输事件路由时的已处理特性。This can affect the handled characteristics of the event as it travels the event route. 有关详细信息,请参阅输入概述For details, see Input Overview.

除了与所有路由事件相关的 @no__t 0 属性以外,MouseEventHandler 实现中可能使用的 @no__t 的最有趣的属性是公开当前按钮状态(如 LeftButton)和 @no__t)的几个属性。Other than the RoutedEventArgs properties that are relevant for all routed events, the most interesting properties of MouseEventArgs that you might use in a MouseEventHandler implementation are several properties that expose the current button state (such as LeftButton) and MouseDevice). MouseDevice 特别有用,因为你可以对其查看 @no__t。MouseDevice is useful particularly because you can check Captured on it.

请注意,专门处理鼠标按钮事件的事件使用不同的事件数据类,MouseButtonEventArgsNote that events that specifically deal with mouse button events use a different event data class, MouseButtonEventArgs. 鼠标按钮属性在 MouseEventArgs 上可用,以防有输入模式或涉及按钮的交互,即使正在处理非按钮事件也是如此。The mouse button properties are available on MouseEventArgs in case there are input modes or interactions that involve the buttons even if you are handling a non-button event.

@No__t-0 类提供附加属性和方法来确定鼠标的状态。The Mouse class provides additional properties and methods for determining the state of the mouse.

构造函数

MouseEventArgs(MouseDevice, Int32)

使用指定的 MouseDevice 和时间戳初始化 MouseEventArgs 类的新实例。Initializes a new instance of the MouseEventArgs class using the specified MouseDevice and timestamp.

MouseEventArgs(MouseDevice, Int32, StylusDevice)

使用指定的 MouseEventArgs、时间戳和 MouseDevice 初始化 StylusDevice 类的新实例。Initializes a new instance of the MouseEventArgs class using the specified MouseDevice, timestamp, and StylusDevice.

属性

Device

获取启动此事件的输入设备。Gets the input device that initiated this event.

(继承自 InputEventArgs)
Handled

获取或设置一个值,该值指示针对路由事件(在其经过路由时)的事件处理的当前状态。Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.

(继承自 RoutedEventArgs)
LeftButton

获取鼠标左键的当前状态。Gets the current state of the left mouse button.

MiddleButton

获取鼠标中键的当前状态。Gets the current state of the middle mouse button.

MouseDevice

获取与此事件关联的鼠标设备。Gets the mouse device associated with this event.

OriginalSource

在父类进行任何可能的 Source 调整之前,获取由纯命中测试确定的原始报告源。Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.

(继承自 RoutedEventArgs)
RightButton

获取鼠标右键的当前状态。Gets the current state of the right mouse button.

RoutedEvent

获取或设置与此 RoutedEventArgs 实例关联的 RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance.

(继承自 RoutedEventArgs)
Source

获取或设置对引发事件的对象的引用。Gets or sets a reference to the object that raised the event.

(继承自 RoutedEventArgs)
StylusDevice

获取与此事件关联的触笔设备。Gets the stylus device associated with this event.

Timestamp

获取此事件发生时的时间。Gets the time when this event occurred.

(继承自 InputEventArgs)
XButton1

获取第一个鼠标扩展按钮的当前状态。Gets the current state of the first extended mouse button.

XButton2

获取第二个鼠标扩展按钮的当前状态。Gets the state of the second extended mouse button.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetPosition(IInputElement)

返回鼠标指针相对于指定元素的位置。Returns the position of the mouse pointer relative to the specified element.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InvokeEventHandler(Delegate, Object)

以特定于类型的方式调用事件处理程序,这样做可以提高事件系统效率。Invokes event handlers in a type-specific way, which can increase event system efficiency.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnSetSource(Object)

在派生类中重写时,每当实例的 Source 属性的值发生更改,则提供一个通知回调入口点。When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes.

(继承自 RoutedEventArgs)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅