加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 触摸输入和直接操作

发布时间:2020-12-15 20:53:45 所属栏目:百科 来源:网络整理
导读:我正在听几个事件来处理 Windows(Phone)8.1运行时代码中的触摸输入.只要不涉及ScrollViewer,这种方法就可以正常工作.由于 Direct Manipulation,ScrollViewer会吞下所有手势事件. 以下是我现在收听的事件(view是一个FrameworkElement): var cw = Window.Curr
我正在听几个事件来处理 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并且不再调用其他事件处理程序.

Rob Caplan wrote in 2013:

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上面使用一些透明层,然后将事件转发给它(要么在第一次完成处理之后,要么等待它先处理它们,但要记住它们之后要对它们采取哪些操作)?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读