locked
TextBox control dont show virtual keyboard after setting focus by code second time

    Question

  • I have problem with Textbox control, more specifficaly with focus and virtual keyboard. I have view with few TextBoxs, I set focus in TextBox with this code: TextBox.Focus(FocusState.Programmatic); and everything is fine. TextBox gets focus, virtual keyboard shows. Then I hide Keyboard with button from virtual keyboard. Then I try to give focus to other TextBox in the same way. TextBox2.Focus(FocusState.Programmatic); and TextBox2 gets focus but virtual keyboard don't show. When I click this TextBox virtual keyboard shows, but TextBox.Focus(FocusState.Programmatic); don't work anymore after i use hide keyboard button form virtual keyboard.

    I tried this on blank view without other controls. I have to set focus by code in my project. And this issue is big problem for me. Does anybody know solution for this problem?

    Wednesday, September 17, 2014 6:15 AM

Answers

All replies

  • Did you implement your own virtual keyboard ? (If you're referring to the on-screen keyboard in Windows 8 it shows up automatically when a text box receives focus, so long as it has been enabled to do so in PC Settings).
    Wednesday, September 17, 2014 6:31 AM
  • I dont implement my own keyboard. I use System keyboard. I tried to give focus to another control (Button or other TextBox) after TextBox lost focus. But the effect is the same. Virtual keyboard dont show second time.
    Wednesday, September 17, 2014 6:52 AM
  • This is expected. The user hid the keyboard and so the user's preference is respected. The keyboard will return when the user taps a text control or explicitly shows it.

    What is your scenario? Why do you have to set focus by code?

    Usually people asking this are trying to hack the keyboard open because they have custom text input controls which don't supply the UIA text pattern and so don't trigger the keyboard properly. The right solution for this case is to support the text pattern.

    See The touch keyboard and http://code.msdn.microsoft.com/windowsapps/Touch-keyboard-sample-43532fda

    Wednesday, September 17, 2014 2:49 PM
    Owner
  • I dont have custom TextInput, I use TextBox control.

    It's very hard to explain why I have to give focus to TextBox from the code not from the Tap. It's part of bigger project, appalication for reading interactive books. I have to give focus this way to the TextBox. I understan now that this is not a bug but expected behavior of virtual keyboard. When user clicks hide button from virtual keyboard it dont show any more after I give focus from the code to TextBox.

    So the question is: Is there any way in TextBox to show virtual keyboard from the code(not from the tap) after I give it focus from the code then user hides it using "hide keyboard" button from virtual keyboard? 


    Wednesday, September 17, 2014 9:23 PM
  • No. The intent is for the keyboard to be under the user's control. See User-driven invocation in The touch keyboard documentation I linked previously.
    • Marked as answer by usatek Thursday, September 18, 2014 7:41 AM
    Wednesday, September 17, 2014 9:57 PM
    Owner
  • Thanks. You explanation was very helpfull. Now we know that giving focus to the TextBox from the code is dead end, we have to find other solution to fix our problem. 
    • Edited by usatek Thursday, September 18, 2014 11:01 AM
    Thursday, September 18, 2014 7:41 AM