Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pressing multiple buttons simultaneously

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.

like image 486
sternr Avatar asked Jul 01 '12 22:07

sternr


People also ask

Why can't I press 3 keys at once?

This is known as Anti ghosting which is usually available in gaming keyboards. But as you can't even use more than 3 keys , means that you are using either a cheap or a office keyboard which is completely not made for gaming. So buy a gaming keyboard with anti ghosting and then you are good to go.

Why can't I press 2 keys at the same time?

In order to save money, keyboard manufacturers often put many keys on the same "circuit" of sorts within the wiring of the keyboard. This prevents multiple keys in the same region of the keyboard from being pressed simultaneously.

What does pressing simultaneously mean?

It just means that things are happening at the same time. If a presidential debate is broadcast simultaneously on three television channels, “broadcast” is the only action but it's happening in three places at once.


1 Answers

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.

like image 190
Darcon Avatar answered Sep 28 '22 00:09

Darcon