locked
Creating own text edit control.

    Question

  • Hello.

    I need in my game such a typical text edit control, and i wonder, in what way i can do this? Maybe it is easily to use a xaml control(if it exist what is call)? or creating a own text control(my problem is keyboard in touch screen devices) I'm sure, that you will help me. Thanks a lot.

    Wednesday, November 12, 2014 10:18 PM

Answers

  • You can get the key presses by subscribing to key events on your CoreWindow. For text entry you probably want to listen to CharacterReceived rather than the raw keys.

    Supporting text pattern is required to show the soft keyboard on Windows without the user explicitly opening it (Windows Phone has TryOpen and TryClose methods). You either need to implement it yourself or use a control (such as the xaml TextBox) which already implements it.

    Tarh ik's link is about general command input in a DX app. It isn't relevant to text input on a touch system.


    Sunday, November 16, 2014 3:06 PM
    Moderator

All replies

  • The easiest way is to interop to a Xaml TextBox. You can easily layer Xaml controls on top of your DX scene as described in the DirectX and XAML interop (Windows Runtime apps using DirectX with C++) documentation.

    If you want to create your own TextBox from scratch then you can do so, but it's more difficult. You will need to implement the UI Automation TextPattern so the system can know when the focus goes to the text control and opens the soft keyboard. See the UI Automation Provider Programmer's Guide .

    If you want to support IMEs, Ink, or other non-keyboard input then you'll need to implement the control as Text Services Framework enabled, but we don't have any samples or direct documentation on how to do so beyond the TSF Reference .

    Wednesday, November 12, 2014 11:47 PM
    Moderator
  • I'm interested in second option, because in first i cannot display it that way, i want, so is the way to run soft keyboard without running this textpattern, and if is posibility, how can i get pressed keys, can be a typical code used for typical keyboard?
    Friday, November 14, 2014 2:04 PM
  •      Hi MiXenXd,

         Well, to implement pressed keys, the following link could be of great help:

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh452773.aspx

     * This article is some sort of tutorial about how to implement input information in your DirectX game.
     * Note that around the middle of the article you may notice the implementation of "OnKeyDown" and "OnKeyUp" events. 
     * You could follow the tutorial to implement your own custom "TextBox" entry. That's what I did.
     * A note of caution: It is going to be painful, as when the user presses the "window" key you could lost track of what keys were pressed and what keys were released.

         I hope it helps!!!

         Tarh Ik

    PS: This posting has been posted "AS IS"


    Tarh ik

    Sunday, November 16, 2014 6:10 AM
  • You can get the key presses by subscribing to key events on your CoreWindow. For text entry you probably want to listen to CharacterReceived rather than the raw keys.

    Supporting text pattern is required to show the soft keyboard on Windows without the user explicitly opening it (Windows Phone has TryOpen and TryClose methods). You either need to implement it yourself or use a control (such as the xaml TextBox) which already implements it.

    Tarh ik's link is about general command input in a DX app. It isn't relevant to text input on a touch system.


    Sunday, November 16, 2014 3:06 PM
    Moderator
  • Thanks for help, but I decidec to create my onw soft keyboard, but I have one little problem and I don't want create a new thread so I ask here:what is the best way to check if i use a smartphone or a tablet without keyboard?
    Thursday, November 20, 2014 11:55 PM
  • It doesn't generally matter if the device has a keyboard: it matters if the user is using it. In general you'll get the best results if you follow the input the user provides. If the app receives touch input then optimise for touch. If the app receives keyboard input then accept the keyboard input.
    Friday, November 21, 2014 12:07 AM
    Moderator
  • So in what way i can check, if a user using touch input(i add that i use xinput). I don't have a specific type of pointer than a typical cursor. What is the best solution?
    Sunday, November 23, 2014 11:21 PM
  • Touch, pen, and mouse input all come through the same Pointer* events.

    You can check the PointerPoint->PointerDevice->PointerDeviceType property to see if a specific event originated from touch, pen, or mouse.

    Wednesday, December 3, 2014 12:45 AM
    Moderator