如何检测笔按钮按下和释放事件

问题描述:

有什么办法如何检测当用户按下或释放APP上的笔按钮?如何检测笔按钮按下和释放事件

要么顶部按钮,或“右击”按钮上表面笔

或者,如何检测,当笔触摸InkCanvas按钮被按下。

enter image description here

您可以订阅PointerPressed上InkCanvas事件。它有参数PointerRoutedEventArgs和。过滤您的输入设备和单独的按钮是这样的:

if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen) 
{ 
    var point = e.GetCurrentPoint(YourCanvasName); 
    if (point.Properties.IsLeftButtonPressed) 
    { 
     //Button1 
    } 
    if (point.Properties.IsMiddleButtonPressed) 
    { 
     //Button2 
    } 
    if (point.Properties.IsRightButtonPressed) 
    { 
     //Button3 
    } 
} 

应该工作,虽然我没有笔测试:)

+0

我都试过'inkCanvas.PointerPressed'和'InkCanvas.InkPresenter。 UnprocessedInput.PointerPressed'bot都不会触发它们,既不是当我按下按钮时,也不是当笔按下按钮时触摸画布。 – Liero