c# – 触摸输入和直接操作
作者:互联网
我正在听几个事件来处理Windows(Phone)8.1运行时代码中的触摸输入.只要不涉及ScrollViewer,这种方法就可以正常工作.由于Direct Manipulation,ScrollViewer会吞下所有手势事件.
以下是我现在收听的事件(view是一个FrameworkElement):
var cw = Window.Current.CoreWindow;
cw.PointerPressed += OnPointerPressed;
cw.PointerMoved += OnPointerMoved;
cw.PointerReleased += OnPointerReleased;
cw.PointerCaptureLost += OnPointerCaptureLost;
view.Tapped += onTap;
view.DoubleTapped += onDoubleTap;
view.Holding += onHold;
view.ManipulationDelta += onManipulationDelta;
view.ManipulationCompleted += onManipulationCompleted;
一旦ScrollViewer识别出一个水龙头,我就会得到一个PointerCaptureLost并且不再调用其他事件处理程序.
Unfortunately there is no good solution if the app needs both scrolling and gestures (for example, to detect CrossSlides against the scrolling). In this case the only option to get the Pointer messages everywhere is to disable Direct Manipulation everywhere, but that disables scrolling as well. To get that back the app will need to detect the scrolling gestures itself and then navigate the ScrollViewer to the new location with ScrollToHorizontalOffset or ScrollToVerticalOffset or by updating the SelectedIndex. This is tricky and will be noticeably slower than letting the ScrollViewer do its thing. It should be avoided if at all possible.
在此期间有变化吗?有人知道这样做的样本吗?
我正在编写一个抽象概念,将手势事件转换为不同的事件.用户可以在其中放置任何控件,我也不知道,他可以用它做什么.所以我不能放慢它只是为了获得手势事件.
ScrollViewer旁边是否还有其他类似的控件?
Windows.UI.Input.GestureRecognizer可以帮助吗?由于UIElement已经提供了我需要的所有活动,我没有尝试过 – 而且我不明白为什么有人应该这样做.
解决方法:
为什么不在ScrollViewer上面使用一些透明层,然后将事件转发给它(要么在第一次完成处理之后,要么等待它先处理它们,但要记住它们之后要对它们采取哪些操作)?
标签:c,touch,swipe,windows-runtime,windows-phone 来源: https://codeday.me/bug/20190711/1434354.html