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
要与此手势进行比较的输入事件数据。
返回
示例
下面的示例演示如何测试与与实例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