Redigera

Dela via


MouseGesture.Matches(Object, InputEventArgs) Method

Definition

Determines whether MouseGesture matches the input associated with the specified InputEventArgs object.

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

Parameters

targetElement
Object

The target.

inputEventArgs
InputEventArgs

The input event data to compare with this gesture.

Returns

true if the event data matches this MouseGesture; otherwise, false.

Examples

The following example shows how to test whether a MouseGesture matches the input associated with an instance of an InputEventArgs. A MouseDown event handler compares the event data with the MouseGesture by using the Matches method.

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

Applies to