Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual Keyboard not appear in WPF #1736

Closed
BriceJantieu opened this issue Jul 6, 2016 · 17 comments
Closed

Virtual Keyboard not appear in WPF #1736

BriceJantieu opened this issue Jul 6, 2016 · 17 comments

Comments

@BriceJantieu
Copy link

BriceJantieu commented Jul 6, 2016

Hello,

I've some issues with the virtual keyboard in the WebView on a Dell Optiplex 7440 used in tablet mode, without physical keyboard plugged.

  • What version of the product are you using?
    • NuGet 39.0.2 / 47.0.2 / 47.0.4 / 49.0.0 / 49.0.1
  • What architecture x86 or x64?
    • x64
  • On what operating system?
    • Win10
  • Are you using WinForms, WPF or OffScreen?
    • WPF
  • What steps will reproduce the problem?
    • Simply create a webview, go on google and touch the search bar (or any input text of any website)
  • What is the expected output? What do you see instead?
    • The native virtual keyboard of Win10 should appear. Instead, nothing happen.
  • Please provide any additional information below.
    • The application must be used with touch screen. No physical keyboard will finally be pluged. So, when I touch a search bar or a textbox in the webview, the native virtual keyboard should appear, like it does when using Chrome or any app where text can be entered. I can only make the virtual keyboard to appear in WinForm example, but not with the WPF one...
  • Does this problem also occur in the Cef TestApp from http://cefbuilds.com?
    • Yes, but only in the webview; in the url bar, the virtual keyboard appear.
@amaitland

This comment has been minimized.

@amaitland amaitland added the wpf label Jul 6, 2016
@bbriot

This comment has been minimized.

@amaitland

This comment has been minimized.

@johnoso27

This comment has been minimized.

@amaitland

This comment has been minimized.

@johnoso27

This comment has been minimized.

@jeffxpx
Copy link

jeffxpx commented Nov 11, 2016

I got in touch with someone at Microsoft about the new virtual keyboard support in WPF 4.6.2 and here's what they said:

If you have Windows 10 Anniversary Edition (or higher) and are running in tablet mode (WPF respects the settings of the touch KB itself) and touch a control that can get keyboard focus and reports itself as implementing the text UIAutomation pattern, then you should see the keyboard pop up.

Your more specific question of the type of KB shown has to do with the InputScope property on a control. You can set InputScope to one of these values and it should react to your specification.

I'm going to play around with this over the coming days / weeks and let you know what I find. Thankfully for testing I can just subclass ChromiumWebBrowser and override OnCreateAutomationPeer and see what sort of stuff I can make work. Once I get it into a good enough state, I'll take the code I put in the subclass and add it to ChromiumWebBrowser and send over a PR.

@johnoso27
Copy link

Thanks, I tested DisableWPFTabletSupport method recomended by microsoft to show the virtual keyboard, but as concecuence fails the touch scroll. I can´t update the framework .Net, the app is developed based in framework 4.

@mismaiel62

This comment has been minimized.

@amaitland

This comment has been minimized.

@amaitland

This comment has been minimized.

@amaitland
Copy link
Member

OnVirtualKeyboardRequested was added in #2689

Currently there is no default implementation, you will have to inherit ChromiumWebBrowser and override OnVirtualKeyboardRequested to implement one for now.

https://github.com/maximcus/WPFTabTip looks promising, will need to investigate further.

@jeffxpx
Copy link

jeffxpx commented Apr 5, 2019

@amaitland The way WPFTabTip does it (opening and killing tabtip.exe) will lead to lots of sadness. You want to use the InputPane APIs from the Windows Runtime.

See: https://github.com/Microsoft/WPF-Samples/blob/master/Input%20and%20Commands/TouchKeyboard/TouchKeyboardNotifier/InputPaneRcw.cs

and https://github.com/Microsoft/WPF-Samples/blob/master/Input%20and%20Commands/TouchKeyboard/TouchKeyboardNotifier/TouchKeyboardEventManager.cs#L340..L350 for how to get an instance of an InputPane

Once you have an instance, you can use TryShow() and TryHide().

https://docs.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.tryshow

@amaitland
Copy link
Member

You want to use the InputPane APIs from the Windows Runtime.

@jeffxpx How does this behave on Windows 7?

Once you have an instance, you can use TryShow() and TryHide().

https://docs.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.inputpane.tryshow

This looks like APIs from UWP, not sure we can use those in a general sense as I'm not sure they're supported on all platforms we support, Win 7, 8.1, 10.

With version 73 anyone will be able to choose their own implementation.

@amaitland amaitland added this to the 73.0.0 milestone Apr 6, 2019
@amaitland
Copy link
Member

As WPF doesn't have an actual API for showing the virtual keyboard, I'm leaving this it up to the user to select the appropriate solution for their needs. If Microsoft ever comes to the party then we can include a default implementation. A VirtualKeyboardRequested event has been added to make it trivially easy to be notified.

An example of using it will look like

private void BrowserVirtualKeyboardRequested(object sender, VirtualKeyboardRequestedEventArgs e)
{
	var inputPane = touchKeyboardEventManager.GetInputPane();

	if (e.TextInputMode == TextInputMode.None)
	{
		inputPane.TryHide();
	}
	else
	{
		inputPane.TryShow();
	}
}

I've provided a very basic Windows 10 example below, others using Windows 8 may need to use something like https://github.com/maximcus/WPFTabTip

Someone can contribute a Windows 7 example if they like, I don't have a Windows 7 machine at the moment, so not really possible.


  • VirtualKeyboardRequested event added in commit cddece0

  • Windows 10 Only example added in commit 0b57e52

Code adapted from https://github.com/Microsoft/WPF-Samples/blob/master/Input%20and%20Commands/TouchKeyboard/TouchKeyboardNotifier/Readme.md (which is thankfully MIT licensed).

@amaitland
Copy link
Member

amaitland commented Apr 6, 2019

@amaitland
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants