MouseEventArgs Class

Definition

提供滑鼠相關路由事件的資料,這些事件並不特別涉及滑鼠按鈕或滑鼠滾輪,例如 MouseMoveProvides 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
Inheritance
Derived

Remarks

這個事件資料類別會與下列附加事件搭配使用。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.

除了與所有路由事件相關的 RoutedEventArgs 屬性外,您可能在 MouseEventHandler 的執行中使用之 MouseEventArgs 最有趣的屬性,就是會公開目前按鈕狀態的數個屬性(例如 LeftButton)和 MouseDevice)。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 特別有用,因為您可以在其上檢查 CapturedMouseDevice 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.

Mouse 類別提供其他屬性和方法來判斷滑鼠的狀態。The Mouse class provides additional properties and methods for determining the state of the mouse.

Constructors

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.

Properties

Device

取得初始化這個事件的輸入裝置。Gets the input device that initiated this event.

(Inherited from 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.

(Inherited from 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.

(Inherited from RoutedEventArgs)
RightButton

取得滑鼠右鍵的目前狀態。Gets the current state of the right mouse button.

RoutedEvent

取得或設定與這個 RoutedEventArgs 執行個體相關聯的 RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance.

(Inherited from RoutedEventArgs)
Source

取得或設定引發事件之物件的參考。Gets or sets a reference to the object that raised the event.

(Inherited from RoutedEventArgs)
StylusDevice

取得與這個事件相關聯的手寫筆裝置。Gets the stylus device associated with this event.

Timestamp

取得這個事件發生的時間。Gets the time when this event occurred.

(Inherited from InputEventArgs)
XButton1

取得第一個延伸的滑鼠按鍵的目前狀態。Gets the current state of the first extended mouse button.

XButton2

取得第二個延伸的滑鼠按鍵的目前狀態。Gets the state of the second extended mouse button.

Methods

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetPosition(IInputElement)

傳回滑鼠指標相對於指定之項目的位置。Returns the position of the mouse pointer relative to the specified element.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from 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.

(Inherited from 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.

(Inherited from RoutedEventArgs)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also