• Advertisement
Sign in to follow this  

WP7 How to get keyboard input synchronously

This topic is 1939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone,

I'm trying to have the user input their name using

if (!Guide.IsVisible)
{
// display the guide
Guide.BeginShowKeyboardInput(PlayerIndex.One,
"Name entry", // title for the page
"Enter your name", // question for user
"Fred", // default text
asyncResult =>
{
InputtedText = Guide.EndShowKeyboardInput(asyncResult);
System.Diagnostics.Debug.WriteLine(InputtedText);
},
this); // object reference
}


but this runs Asynchronously. I need this to be modal because I do not want anything else to continue processing until I get the user input. Does anyone know how to do this? The work around I used for the messagebox on WP7 was to use Silverlights implementation of MessageBox as opposed to XNA's Guide.BeginShowMessageBox. Why would they make these things asynchronous!? >:[

Share this post


Link to post
Share on other sites
Advertisement
Under winforms I believe the messagebox class had both synchrous and asynchrous versions, is this not the case in XNA?
Otherwise I'm sorry, I have no idea.

Share this post


Link to post
Share on other sites
They do not and winforms can't be used on the windows phone because they don't have the libraries on the phone or something like that =/

Share this post


Link to post
Share on other sites
I'm just throwing something out there but what about using Guide.IsVisible for the other game-related logic as well? Something like:

if (!Guide.IsVisible)
{
//perform game-related logic
}
else
{
//pause the game.
}


I've never tried something like that though - so, it's just a shot in the dark.

-Shadow Edited by ShadowValence

Share this post


Link to post
Share on other sites
If anyone else is having this problem, I just used an infinite loop while(!asyncResult.IsCompleted){}. Alternatively, I think there is wait for the thread to finish property but I don't remember where exactly it is.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement