简体   繁体   中英

UWP unable to enter data in textbox in webview with custom OSK

I have an angular app running in webview and a custom OnScreen Keyboard(OSK) in uwp. I am unable to enter data in the textbox present in webview using the custom OSK though it is working fine for normal UWP textbox. It seems to lose focus when i click on OSK.

I have tried WebView.Focus(FocusState.Programmatic) and invoking scripts using InvokeScriptAsync for setting the focus back to the webview in WebView LostFocus event but nothing worked.

I tried using focusmanager as well.

FocusMovementResult result;
result = await FocusManager.TryFocusAsync(WebView, FocusState.Programmatic);

I am injecting input in the textbox using InputInjector .

inputKey.VirtualKey = ((ushort)((VirtualKey)Enum.Parse(typeof(VirtualKey), input.Text, true)));
inputInjector.InjectKeyboardInput(new[] { inputKey });

Also the AllowFocusOnInteraction property is set to False for OSK. <app:Keyboard x:Name="keyboard" AllowFocusOnInteraction="False"/>

I was able to resolve it by notifying UWP with window.external.notify about the blur event using event listener and with this notified command set focus back to webview using

webview.Focus(FocusState.Programmatic);
await webView.InvokeScriptAsync(@"eval", new string[] { "document.focus()" });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM