如何检测笔按钮按下和释放事件
答
您可以订阅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
}
}
应该工作,虽然我没有笔测试:)
我都试过'inkCanvas.PointerPressed'和'InkCanvas.InkPresenter。 UnprocessedInput.PointerPressed'bot都不会触发它们,既不是当我按下按钮时,也不是当笔按下按钮时触摸画布。 – Liero