同时按下多个按钮 [英] Pressing multiple buttons simultaneously

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

问题描述

在我的WP 7.1的应用程序我有多个按钮的页面。结果
我注意到,在按下任何一个按钮时,没有其他按钮可以被按下。



我怎样才能解决这个?我需要能够让用户在同一时间按多个按钮


解决方案

您不能处理多个按钮点击在一次不幸。有办法解决它虽然。您可以使用Touch.FrameReported事件让所有用户在触摸屏幕上的点的位置(我在这之前就WP7是两限读的地方,但我不能验证)。您还可以检查用户是否正在采取行动(如向下,移动和向上),这取决于你在做什么,这可能很有用。在Application_Startup



将这个

  Touch.FrameReported + =新TouchFrameEventHandler(Touch_FrameReported); 

在你的App类



<$ P将这个$ p> 无效Touch_FrameReported(对象发件人,TouchFrameEventArgs E)
{
接触点primaryTouchPoint = args.GetPrimaryTouchPoint(NULL);


TouchPointCollection接触点= args.GetTouchPoints(NULL);


的foreach(在接触点接触点TP)
{
如果(tp.Action == TouchAction.Down)
{
//这里要做的东西
}

}
}

在在这里做的东西的一部分,你会检查是否接触点TP是一个按钮占据区域内。

  //这是你的按钮的位置,变化值所需的矩形。 
矩形R1 =新的Rectangle(0,0,100,100);
如果(r1.Contains(tp.Position))
{
//这里执行按钮点击的东西。
}

这应该有希望为您代劳。


In my WP 7.1 app I have a page with multiple buttons.
I noticed that while any one button is being pressed, no other button can be pressed.

How can I overcome this? I need to be able to allow users to press multiple buttons at the same time.

解决方案

You can't handle multiple button clicks at once unfortunately. There is a way around it though. You can use the Touch.FrameReported event to get the position of all the points a user is touching on the screen (I read somewhere before that on WP7 it's limited to two but I can't verify that). You can also check if the action the user is taking (e.g. Down, Move and Up) which may be useful depending on what you are doing.

Put this in your Application_Startup

Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);

Put this in your App class

void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
    TouchPoint primaryTouchPoint = args.GetPrimaryTouchPoint(null);


    TouchPointCollection touchPoints = args.GetTouchPoints(null);


    foreach (TouchPoint tp in touchPoints)
    {
        if(tp.Action == TouchAction.Down)
        {
        //Do stuff here
        }

    }
}

In the "Do stuff here" part you would check if the TouchPoint tp is within an area a button occupies.

//This is the rectangle where your button is located, change values as needed.
Rectangle r1 = new Rectangle(0, 0, 100, 100); 
if (r1.Contains(tp.Position))
{
   //Do button click stuff here.
}

That should hopefully do it for you.

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

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