检测多个同时触摸 [英] Detecting more than one simultaneous touch

查看:59
本文介绍了检测多个同时触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows Phone 8(在Lumia 920上测试)中,我使用System.Windows.Input。 Touch.FrameReported事件处理触摸事件。当用户用单个手指触摸屏幕时,事件被提升。完善。但是,当用户用
两个手指同时触摸屏幕时,该事件根本不会被提升。完全没有。 如果用户错开了他们的两次触摸(不同时但几乎同时),则会引发事件并在单个事件中报告两个点。

In Windows Phone 8 (testing on a Lumia 920) I use the System.Windows.Input.Touch.FrameReported event to handle touch events. When the user touches the screen with a single finger the event is raised. Perfect. However, when the user touches the screen with two fingers at EXACTLY the same time, the event is not raised at all. Not at all. If the user staggers their two touches (not simultaneous but almost simultaneous) the event is raised and both points are reported in the single event.

问题显然是同时接触是"丢失"。

The problem, obviously, is that the simultaneous touches are "lost".

如何检测到两个(或更多)同时接触?

Jerry Nixon

Jerry Nixon

推荐答案

这段代码必须有效:)

This piece of code must work :)

void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            TouchPointCollection points = e.GetTouchPoints(this);
            int numPoints =(from p in points where p.Action != TouchAction.Up select p).Count();

//Show numbers of touches, simultaneously too            
MessageBox.Show(numPoints.ToString());
        }

希望有所帮助。


这篇关于检测多个同时触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆