MouseGesture.Matches(Object, InputEventArgs) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷是否 MouseGesture 符合與指定 InputEventArgs 物件相關的輸入。
public:
override bool Matches(System::Object ^ targetElement, System::Windows::Input::InputEventArgs ^ inputEventArgs);
public override bool Matches(object targetElement, System.Windows.Input.InputEventArgs inputEventArgs);
override this.Matches : obj * System.Windows.Input.InputEventArgs -> bool
Public Overrides Function Matches (targetElement As Object, inputEventArgs As InputEventArgs) As Boolean
參數
- targetElement
- Object
目標。
- inputEventArgs
- InputEventArgs
輸入事件資料用來與此手勢比較。
傳回
true 若事件資料符合此 MouseGesture;否則, false。
範例
以下範例說明如何測試 a MouseGesture 是否與 實例 InputEventArgs相關聯的輸入相符。 MouseDown事件處理程式會透過 的方法MouseGesture將事件資料與 Matches 進行比較。
private void OnMouseDown(object sender, MouseEventArgs e)
{
MouseGesture mouseGesture = new MouseGesture(MouseAction.MiddleClick,ModifierKeys.Control);
if (mouseGesture.Matches(null, e))
{
MessageBox.Show("Trapped Mouse Gesture");
}
}
Private Overloads Sub OnMouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim mouseGesture As New MouseGesture(MouseAction.MiddleClick,ModifierKeys.Control)
If mouseGesture.Matches(Nothing, e) Then
MessageBox.Show("Trapped Mouse Gesture")
End If
End Sub