Tag: guide
How to access to Keyboard in XNA for Windows Phone 7
by Guerrerotook on Jul.17, 2010, under Windows Phone 7
One of the great thinks about developing on XNA is that you have access to low level graphics to draw your sprites and your 3d mesh, but sometimes you need some high level component to provide some functionality to the user like for example a keyboard.
If you plan the user on Windows Phone 7 to type the name to start a new game you need to create your own keyboard and textbox support. This can be a little bit hard, so that why Microsoft include a simple API to show a Task in the Phone in order the user write some text and return this string back to you.
Guide.BeginShowKeyboardInput(
PlayerIndex.One,
"You Win",
"Insert your name",
"",
new AsyncCallback(OnEndShowKeyboardInput),
null);
With this code you are invoking the Keyboard Task, you need to keep in mind that your application will be deactivated and If you have code there will be executed, once the user finish to type the name and tap on accept button will return back to your application.
private void OnEndShowKeyboardInput(IAsyncResult result) { name = Guide.EndShowKeyboardInput(result); }
Here is where you get the string that the user typed.
You can download simple demo showing this functionality from here.
Luis Guerrero.