Mouse 类

定义

将鼠标设备表示为特定线程。Represents the mouse device to a specific thread.

public ref class Mouse abstract sealed
public static class Mouse
type Mouse = class
Public Class Mouse
继承
Mouse

注解

Mouse类提供与鼠标相关的事件、方法和属性, 这些属性提供有关鼠标状态的信息。The Mouse class provides mouse related events, methods and, properties which provide information regarding the state of the mouse.

定义为附加Mouse事件的每个事件也由基元素类UIElementContentElement新的路由事件重新公开。Each event that Mouse defines as an attached event is also re-exposed by the base element classes UIElement and ContentElement as a new routed event. 通常, 在和UIElement ContentElement上处理应用程序的鼠标事件更方便Mouse , 而不是使用事件。Generally, it is more convenient to handle mouse events for an application on UIElement and ContentElement, rather than using the Mouse events. 有关详细信息, 请参阅输入概述For details, see Input Overview.

Mouse类的静态成员委托给调用线程的输入MouseDevice管理器的主成员。The static members of the Mouse class delegate to the primary MouseDevice of the calling thread's input manager.

字段

GotMouseCaptureEvent

标识 GotMouseCapture 附加事件。Identifies the GotMouseCapture attached event.

LostMouseCaptureEvent

标识 LostMouseCapture 附加事件。Identifies the LostMouseCapture attached event.

MouseDownEvent

标识 MouseDown 附加事件。Identifies the MouseDown attached event.

MouseEnterEvent

标识 MouseEnter 附加事件。Identifies the MouseEnter attached event.

MouseLeaveEvent

标识 MouseLeave 附加事件。Identifies the MouseLeave attached event.

MouseMoveEvent

标识 MouseMove 附加事件。Identifies the MouseMove attached event.

MouseUpEvent

标识 MouseUp 附加事件。Identifies the MouseUp attached event.

MouseWheelDeltaForOneLine

代表鼠标滚轮要滚过一行而转动的单位数。Represents the number of units the mouse wheel is rotated to scroll one line.

MouseWheelEvent

标识 MouseWheel 附加事件。Identifies the MouseWheel attached event.

PreviewMouseDownEvent

标识 PreviewMouseDown 附加事件。Identifies the PreviewMouseDown attached event.

PreviewMouseDownOutsideCapturedElementEvent

标识 PreviewMouseDownOutsideCapturedElement 附加事件。Identifies the PreviewMouseDownOutsideCapturedElement attached event.

PreviewMouseMoveEvent

标识 PreviewMouseMove 附加事件。Identifies the PreviewMouseMove attached event.

PreviewMouseUpEvent

标识 PreviewMouseUp 附加事件。Identifies the PreviewMouseUp attached event.

PreviewMouseUpOutsideCapturedElementEvent

标识 PreviewMouseUpOutsideCapturedElement 附加事件。Identifies the PreviewMouseUpOutsideCapturedElement attached event.

PreviewMouseWheelEvent

标识 PreviewMouseWheel 附加事件。Identifies the PreviewMouseWheel attached event.

QueryCursorEvent

标识 QueryCursor 附加事件。Identifies the QueryCursor attached event.

属性

Captured

获取捕获了鼠标的元素。Gets the element that has captured the mouse.

DirectlyOver

获取鼠标指针正好悬停于的元素。Gets the element the mouse pointer is directly over.

LeftButton

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

MiddleButton

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

OverrideCursor

获取或设置整个应用程序的光标。Gets or sets the cursor for the entire application.

PrimaryDevice

获取主鼠标设备。Gets the primary mouse device.

RightButton

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

XButton1

获取第一个扩展按钮的状态。Gets the state of the first extended button.

XButton2

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

方法

AddGotMouseCaptureHandler(DependencyObject, MouseEventHandler)

GotMouseCapture 附加事件添加处理程序。Adds a handler for the GotMouseCapture attached event.

AddLostMouseCaptureHandler(DependencyObject, MouseEventHandler)

LostMouseCapture 附加事件添加处理程序。Adds a handler for the LostMouseCapture attached event.

AddMouseDownHandler(DependencyObject, MouseButtonEventHandler)

MouseDown 附加事件添加处理程序。Adds a handler for the MouseDown attached event.

AddMouseEnterHandler(DependencyObject, MouseEventHandler)

MouseEnter 附加事件添加处理程序。Adds a handler for the MouseEnter attached event.

AddMouseLeaveHandler(DependencyObject, MouseEventHandler)

MouseLeave 附加事件添加处理程序。Adds a handler for the MouseLeave attached event.

AddMouseMoveHandler(DependencyObject, MouseEventHandler)

MouseMove 附加事件添加处理程序。Adds a handler for the MouseMove attached event.

AddMouseUpHandler(DependencyObject, MouseButtonEventHandler)

MouseUp 附加事件添加处理程序。Adds a handler for the MouseUp attached event.

AddMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

MouseWheel 附加事件添加处理程序。Adds a handler for the MouseWheel attached event.

AddPreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler)

PreviewMouseDown 附加事件添加处理程序。Adds a handler for the PreviewMouseDown attached event.

AddPreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

PreviewMouseDownOutsideCapturedElement 附加事件添加处理程序。Adds a handler for the PreviewMouseDownOutsideCapturedElement attached event.

AddPreviewMouseMoveHandler(DependencyObject, MouseEventHandler)

PreviewMouseMove 附加事件添加处理程序。Adds a handler for the PreviewMouseMove attached event.

AddPreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler)

PreviewMouseUp 附加事件添加处理程序。Adds a handler for the PreviewMouseUp attached event.

AddPreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

PreviewMouseUpOutsideCapturedElement 附加事件添加处理程序。Adds a handler for the PreviewMouseUpOutsideCapturedElement attached event.

AddPreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

PreviewMouseWheel 附加事件添加处理程序。Adds a handler for the PreviewMouseWheel attached event.

AddQueryCursorHandler(DependencyObject, QueryCursorEventHandler)

QueryCursor 附加事件添加处理程序。Adds a handler for the QueryCursor attached event.

Capture(IInputElement)

将鼠标输入捕获到指定元素。Captures mouse input to the specified element.

Capture(IInputElement, CaptureMode)

使用指定的 CaptureMode 将鼠标输入捕获到指定元素。Captures mouse input to the specified element using the specified CaptureMode.

GetIntermediatePoints(IInputElement, Point[])

检索以前的自上一个鼠标移动事件以来的鼠标指针坐标(最多可检索 64 个)。Retrieves up to 64 previous coordinates of the mouse pointer since the last mouse move event.

GetPosition(IInputElement)

获取与指定元素相对的鼠标位置。Gets the position of the mouse relative to a specified element.

RemoveGotMouseCaptureHandler(DependencyObject, MouseEventHandler)

删除 GotMouseCapture 附加事件的处理程序。Removes a handler for the GotMouseCapture attached event.

RemoveLostMouseCaptureHandler(DependencyObject, MouseEventHandler)

删除 LostMouseCapture 附加事件的处理程序。Removes a handler for the LostMouseCapture attached event.

RemoveMouseDownHandler(DependencyObject, MouseButtonEventHandler)

删除 MouseDown 附加事件的处理程序。Removes a handler for the MouseDown attached event.

RemoveMouseEnterHandler(DependencyObject, MouseEventHandler)

删除 MouseEnter 附加事件的处理程序。Removes a handler for the MouseEnter attached event.

RemoveMouseLeaveHandler(DependencyObject, MouseEventHandler)

删除 MouseLeave 附加事件的处理程序。Removes a handler for the MouseLeave attached event.

RemoveMouseMoveHandler(DependencyObject, MouseEventHandler)

删除 MouseMove 附加事件的处理程序。Removes a handler for the MouseMove attached event.

RemoveMouseUpHandler(DependencyObject, MouseButtonEventHandler)

删除 MouseUp 附加事件的处理程序。Removes a handler for the MouseUp attached event.

RemoveMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

删除 MouseWheel 附加事件的处理程序。Removes a handler for the MouseWheel attached event.

RemovePreviewMouseDownHandler(DependencyObject, MouseButtonEventHandler)

删除 PreviewMouseDown 附加事件的处理程序。Removes a handler for the PreviewMouseDown attached event.

RemovePreviewMouseDownOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

删除 PreviewMouseDownOutsideCapturedElement 附加事件的处理程序。Removes a handler for the PreviewMouseDownOutsideCapturedElement attached event.

RemovePreviewMouseMoveHandler(DependencyObject, MouseEventHandler)

删除 PreviewMouseMove 附加事件的处理程序。Removes a handler for the PreviewMouseMove attached event.

RemovePreviewMouseUpHandler(DependencyObject, MouseButtonEventHandler)

删除 PreviewMouseUp 附加事件的处理程序。Removes a handler for the PreviewMouseUp attached event.

RemovePreviewMouseUpOutsideCapturedElementHandler(DependencyObject, MouseButtonEventHandler)

删除 PreviewMouseUpOutsideCapturedElement 附加事件的处理程序。Removes a handler for the PreviewMouseUpOutsideCapturedElement attached event.

RemovePreviewMouseWheelHandler(DependencyObject, MouseWheelEventHandler)

删除 PreviewMouseWheel 附加事件的处理程序。Removes a handler for the PreviewMouseWheel attached event.

RemoveQueryCursorHandler(DependencyObject, QueryCursorEventHandler)

移除 QueryCursor 附加事件的处理程序。Removes a handler for the QueryCursor attached event.

SetCursor(Cursor)

将鼠标指针设置到指定的 CursorSets the mouse pointer to the specified Cursor.

Synchronize()

强制同步鼠标重新。Forces the mouse to resynchronize.

UpdateCursor()

强制更新鼠标光标。Forces the mouse cursor to be updated.

附加事件

GotMouseCapture

在元素捕获到鼠标时发生。Occurs when an element captures the mouse.

LostMouseCapture

在元素丢失鼠标捕获时发生。Occurs when an element loses mouse capture.

MouseDown

当按下任何鼠标按钮时发生。Occurs when any mouse button is depressed.

MouseEnter

当鼠标指针进入元素的边界时发生。Occurs when the mouse pointer enters the boundaries of an element.

MouseLeave

当鼠标指针离开元素的边界时发生。Occurs when the mouse pointer leaves the boundaries of an element.

MouseMove

在鼠标指针移动时发生。Occurs when the mouse pointer moves.

MouseUp

当释放任何鼠标按钮时发生。Occurs when any mouse button is released.

MouseWheel

在鼠标滚轮转动时发生。Occurs when the mouse wheel is rotated.

PreviewMouseDown

当按下任何鼠标按钮时发生。Occurs when any mouse button is depressed.

PreviewMouseDownOutsideCapturedElement

当在捕获鼠标事件的元素之外按下主鼠标按钮时发生。Occurs when the primary mouse button is pressed outside the element that is capturing mouse events.

PreviewMouseMove

在鼠标移过元素时发生。Occurs when the mouse moves over an element.

PreviewMouseUp

当释放任何鼠标按钮时发生。Occurs when any mouse button is released.

PreviewMouseUpOutsideCapturedElement

当在捕获鼠标事件的元素之外释放主鼠标按钮时发生。Occurs when the primary mouse button is released outside the element that is capturing mouse events.

PreviewMouseWheel

在鼠标滚轮转动时发生。Occurs when the mouse wheel rotates.

QueryCursor

当元素查询当前鼠标光标时发生。Occurs when an element queries for the current mouse cursor.

适用于