4
votes

I´m developing a WPF app that is supposed to run on a Windows 8 tablet. When it comes to textboxes, I´m having a hard time finding the right way to let the user input text in those textboxes.

I´ve tried using osk.exe and tabtip.exe, but both lack support of size, location, etc. And furthermore, you have to override quite a few events on the textbox, to take care of opening and closing the keyboard (when the user leaves the textbox), etc. All of this to avoid common problems like, for an example, the keyboard slides in on top of the textbox so you cant see what you are typing.

What I miss here is more Windows 8 on screen keyboard support, so I can open a keyboard with different options to choose from.

So my question is; is there a standardized way of handling user text input on windows 8 tablets? Or is Microsoft just "leaving you in the dark"? What does everybody do? It is very easy to create som pretty bad and unproffessional WPF solutions the way it is now.

Thanks.

1
Not a direct answer, but still may be helpfull - How to bring up the on screen keyboard using C++ in Windows 7 tablet devicesSevenate

1 Answers

3
votes

I've just finished developing a touch screen Kiosk, no physical keyboard. I too found the osk limiting.

With the help of a graphic designer, we created our own keyboard, buttons with the background of a key, and the content (or Tag) matching the intent of the button. Assign most buttons to a common event handler that inserts the text at the CaretIndex of the selected control.

Use seperate handlers for DEL and ENTER.

For my application, I popup a new window with a textbox, the desired keyboard (alpha, numeric, both, etc), a helpful sentence prompting the user for input and a placeholder showing the desired format.

It works really well, and gives us complete control over the user experience.

private void key_Click(object sender, RoutedEventArgs e)
{
    _activeControl.SelectedText = (string)((Control)sender).Tag;
    _activeControl.CaretIndex += _activeControl.SelectedText.Length;
    _activeControl.SelectionLength = 0;
    _activeControl.Focus();
}
private void btnDEL_Click(object sender, RoutedEventArgs e)
{
    var ci = _activeControl.CaretIndex;
    if (ci > 1)
    {
        _activeControl.Text = _activeControl.Text.Remove(
                                     _activeControl.CaretIndex - 1, 1);
        _activeControl.SelectionStart = ci - 1;
    }
    else if (_activeControl.Text.Length > 0)
    {
        _activeControl.Text = _activeControl.Text.Remove(0, 1);
    }
    _activeControl.Focus();
}
private void btnEnter_Click(object sender, RoutedEventArgs e)
{
    // Raise an event here, signalling your application 
    // to validate and move to the next field
}