【发布时间】:2016-08-05 15:58:39
【问题描述】:
UWP WebView 的焦点有点奇怪。
我有一个完全被 WebView 覆盖的单页 TestApp。
App 获得焦点时,WebView 控件获得焦点(并接收 GotFocus 事件),但 DOM document.hasFocus 的状态保持为 false。
当用户点击 html 时,document.hasFocus 变为 true,webView 收到 LostFocus 事件。
想要/预期的行为是,如果 App/Page 被激活,WebView 的 内容 会获得焦点。
有什么建议吗?
XAML:
<Page
x:Class="TestApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<WebView x:Name="webView" NavigationStarting="webView_NavigationStarting" GotFocus="webView_GotFocus" LostFocus="webView_LostFocus"/>
</Grid>
</Page>
【问题讨论】: