使用WebView时的UWP Xbox一页导航 [英] UWP Xbox One page navigation when using WebView

查看:164
本文介绍了使用WebView时的UWP Xbox一页导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,在Xbox上运行UWP应用时,将自动处理控制器上的B按钮,并使您返回上一页.

Usually when running a UWP app on Xbox the B button on the controller is handled automatically and will return you to the previous page.

我有一个包含WebView的页面,当您使用方向按钮将焦点框放置在该控件周围时,B按钮不再响应.您可以使用A按钮来控制WebView并显示指针,然后使用B按钮将如上所述返回焦点,但是除非将焦点框移至其他控件,否则我无法使用B按钮进行向后导航.使用AdControl也会发生这种情况,因为它使用的是WebView.

I have a page which contains a WebView, when you use the directional buttons to place the focus box around that control, the B button no longer responds. You can use the A button to take control of the WebView and display the pointer and the B button then will return focus back as above but I cannot navigate back using the B button until you move the focus box to a different control. This also happens using AdControl since this uses WebView.

我尝试捕获KeyDown:

I have tried to capture KeyDown:

Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;

private void CoreWindow_KeyDown(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
{
    Debug.WriteLine(args.VirtualKey.ToString());
}

这会以GamePadB,GamePadX等响应,但是当焦点框位于WebView周围时不会响应.

This responds with GamePadB, GamePadX etc but not when the focus box is around the WebView.

无论如何,当焦点框位于WebView(或AdControl)周围且控件未处于活动状态时,我是否能找到按下GamePad按钮(特别是B)的时间?

Is there anyway I can find out when the GamePad buttons (specifically B) are pressed when the focus box is around the WebView (or AdControl) and the control isn't engaged so I can manually invoke the backstack navigation?

推荐答案

由于在应用程序使用XY聚焦模式时会发生此问题,因此,如果您的操作系统版本为14393或更高版本,则此问题的一种解决方法是使用鼠标通过将RequiresPointer ="WhenFocused"设置为以下内容,可以在此包含Web视图的页面的模式:

Since this issue happens when using the XY focus mode for the app, if your OS version is 14393 or higher, one workaround for this issue is to use the mouse mode for this page which contains the webview by setting RequiresPointer="WhenFocused" as following:

<Page RequiresPointer="WhenFocused">
...
</Page>

然后使用app.xaml.cs中的以下代码将另一页设置为XY聚焦模式:

And set another page to XY focus mode by using the following code in the app.xaml.cs:

this.RequiresPointerMode =
   Windows.UI.Xaml.ApplicationRequiresPointerMode.WhenRequested;

有关更多信息,请尝试参考以下文章:
https://msdn.microsoft.com/zh-CN/windows/uwp/input-and-devices/designing-for-tv#mouse-mode

For more information, please try to refer to the following article:
https://msdn.microsoft.com/en-us/windows/uwp/input-and-devices/designing-for-tv#mouse-mode

这篇关于使用WebView时的UWP Xbox一页导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆