1

OK, I've got a C++/CX/XAML UWP game running on Xbox One.

It has a SwapChainPanel containing a WebView for UI overlay and a Canvas where the game runs.

When I start up the Webview is fullscreen and the canvas isn't doing anything. The controller navigates the Web UI no problem, with up/down/left/right, 'a' for select and 'b' for back/suspend. This navigating is done using the JS Gamepad API, rather than mouse-mode.

The problem comes when I select an input field in the webview. I can highlight the box, I can press A, I can navigate away, but I do not get a cursor in the box and the soft keyboard does not appear. This is the problem; I can't enter anything in the input box.

If, however, I press the 'Xbox button' on the controller to bring up the Guide sidebar, then press the 'Xbox button' again to dismiss it suddenly a cursor appears in the selected input box and a press of 'a' brings up the soft keyboard and everything is fine. From this point on, any textbox I select works absolutely fine.

So, why doesn't it work when I first load the app? What am I not doing that I need to do?

I suspected a focus problem of some kind, but using a GotFocusEventHandler() to report focus events just showed the Webview getting the focus when the app started, and the same when coming back from the Guide sidebar. Forcing a call to webView->Focus(FocusState::Programmatic); when the input box was highlighted had no reported focus event, presumably because the webview was already the focus.

On further investigation the page works fine if I access it via an HTTP URL, but doesn't work if I use HTTPS. I can't see any obvious error messages, and both versions of the URL are present in the Content URIs section of the manifest

Andy Krouwel
  • 1,309
  • 11
  • 21
  • To help you diagnose this issue, could you please provide a [mcve]? – Xie Steven Feb 22 '19 at 02:16
  • I've simplified the app to a slight modification of a basic template app, and the problem's still there, so I suspect it's something in Edge's handling of the WebView on Xbox One. I'll see if I can simplify the webpages. – Andy Krouwel Feb 23 '19 at 18:52
  • Have not got simpler page yet, but have noted that it works fine if I access page via Http, but does not work if I use Https – Andy Krouwel Feb 26 '19 at 15:23

1 Answers1

1

OK, after much investigation and many blind alleys the following code fixed this problem, which I have to assume is a bug in the Edge WebView.

webView->Visibility = Visibility::Collapsed;  
webView->Visibility = Visibility::Visible;    // Yes, I know I just changed this but it needs changing twice.
webView->Focus(FocusState::Programmatic);

If you miss any of these lines out the whole thing doesn't work.

Andy Krouwel
  • 1,309
  • 11
  • 21