Displaying a Software Input Panel (Windows Phone, Xbox 360)

Describes how to show a sofware input panel (SIP).

The Complete Sample

The code in this topic shows you the technique. You can download a complete code sample for this topic, including full source code and any additional supporting files required by the sample.

On systems and devices that lack a hardware keyboard, you can use Guide.BeginShowKeyboardInput to display a software input panel (SIP). This is an asynchronous process for which you can use both polling and callback-style techniques to retrieve user input.

For more information about programming asynchronous methods, see Working with Asynchronous Methods in XNA Game Studio.

To show a software keyboard

  1. Call Guide.BeginShowKeyboardInput to begin display of the keyboard.

    On Windows Phone and Windows, the player index must always be PlayerIndex.One.

    For example:

    kbResult = Guide.BeginShowKeyboardInput(PlayerIndex.One,
            "Here's your Keyboard", "Type something...",
            ((typedText == null) ? "" : typedText),
            GetTypedChars, null);
    If you require a secure input panel that does not display typed characters, use the Guide.BeginShowKeyboardInput (PlayerIndex, String, String, String, AsyncCallback, Object, Boolean) overload that takes a Boolean parameter specifying whether to hide user input.
  2. When IASyncResult.IsCompleted is true, call Guide.EndShowKeyboardInput to retrieve the characters typed in the input panel.

  3. For example:

    protected void GetTypedChars(IAsyncResult r)
        typedText = Guide.EndShowKeyboardInput(r);
Because this process displays a Windows Phone-generated input panel that resizes the display, you should not do any lengthy processing within a few frames of calling BeginShowKeyboardInput or Guide.EndShowKeyboardInput. If you do so, your game may experience odd graphical artifacts as the phone returns the screen back to the resolution and orientation used by your game.

Community Additions