On-screen keyboard in a WPF application on a Win 8 tablet

I am developing a WPF application that should run on a Windows 8 tablet. When it comes to text fields, it's hard for me to find the right way to let the user enter text into these text fields.

I tried using osk.exe and tabtip.exe, but both of them have no support for size, location, etc. In addition, you need to redefine quite a lot of events in the text field to take care of opening and closing the keyboard (when the user leaves the text field), etc. All this in order to avoid such common problems as, for example, the keyboard slides at the top of the text field, so you cannot see what you are typing.

What I missed here is more of Windows 8 on the on-screen keyboard, so I can open the keyboard with various options to choose from.

So my question is; Is there a standardized way to handle user text input on Windows 8 tables? Or is Microsoft just “leaving you in the dark”? What is everyone doing? It is very easy to create som pretty bad and unprofessional WPF solutions as they are now.

Thanks.

+4
source share
1 answer

I just finished developing a touch screen kiosk without a physical keyboard. I also found an osk limitation.

With the help of a graphic designer, we created our own keyboard, buttons with a key background, and content (or tag) that corresponds to the button’s intention. Assign most buttons to a common event handler that inserts text into the CaretIndex of the selected control.

Use separate handlers for DEL and ENTER.

For my application, I display a new window with a text field, the desired keyboard (alpha, numeric, etc.), a useful suggestion that prompts the user to enter data and a placeholder that displays the desired format.

It works very well and gives us full control over the user interface.

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 } 
+2
source

Source: https://habr.com/ru/post/1484224/


All Articles