Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (9 posts)

How to intercept the back button on Windows Phone?

Last post 6/4/2010 2:00 PM by Flint ZA. 8 replies.
  • 5/4/2010 7:41 AM

    How to intercept the back button on Windows Phone?

    The Back button is the only button that an app can intercept on Windows Phone 7, and for a part of our game it is a requirement that we must do a specific non-exiting action when the Back button is pressed.  However the code

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
    
    

    is never returning true.  The app is always being exited, so I'm guessing that either

    1. something else in the XNA Framework is intercepting the Back button first, or
    2. there is another way to detect and intercept the Back button.

    Silverlight has the OnBackKeyPress method that they can override.  How do we intercept the Back button in a XNA app on Windows Phone 7?

  • 5/4/2010 1:49 PM In reply to

    Re: How to intercept the back button on Windows Phone?

    Answer
    Reply Quote
    What build of the Windows Phone Developer Tools are you using? I believe the Back button wasn't hooked up in the original CTP but the April CTP Refresh has this enabled such that hitting back on the emulator triggers the Back button of the game pad.
  • 5/4/2010 10:12 PM In reply to

    Re: How to intercept the back button on Windows Phone?

    Thanks for the answer.  We don't have licenses for VS2010 RTM yet, so we're still on the MIX CTP.  I'll try it when our tech department get the licenses organised.
  • 5/4/2010 10:29 PM In reply to

    Re: How to intercept the back button on Windows Phone?

    Dont forget it will work with c# express 2010 until then!
  • 5/4/2010 10:33 PM In reply to

    Re: How to intercept the back button on Windows Phone?

    The CTP installs its own version of Visual Studio Express as well. You don't actually need any other Visual Studio SKU in order to use the CTP.
  • 5/5/2010 1:22 PM In reply to

    Re: How to intercept the back button on Windows Phone?

    Express unfortunately does not support Perforce integration and solution folders.  I'll just wait the day or two for our licensed versions to come through.
  • 6/4/2010 10:28 AM In reply to

    Re: How to intercept the back button on Windows Phone?

    slygamer2:

    The Back button is the onlybutton that an app can intercept on Windows Phone 7


    Is there any way to at least be notified of other hard button presses? Would be great to know when the player presses the Windows or Bing buttons to at least pause the game. Or is this handled by a guide shown notification?
  • 6/4/2010 11:39 AM In reply to

    Re: How to intercept the back button on Windows Phone?

    Flint ZA:
    Would be great to know when the player presses the Windows or Bing buttons to at least pause the game.
    There is not pausing of games. When either of those happen the Exiting event will be fired. That gives you the chance of save before the game quits.
  • 6/4/2010 2:00 PM In reply to

    Re: How to intercept the back button on Windows Phone?

    Jim Perry:
    Flint ZA:
    Would be great to know when the player presses the Windows or Bing buttons to at least pause the game.
    There is not pausing of games. When either of those happen the Exiting event will be fired. That gives you the chance of save before the game quits.

    Ok, so the current emulator behavior where pressing these buttons takes you to the home screen or search screen respectively, and from there pressing back returns you to your game, is not accurate to final hardware behavior?
Page 1 of 1 (9 posts) Previous Discussion Next Discussion