InputFocusController.GotFocus 事件

定义

在关联的 ContentIsland 接收焦点时发生。

// Register
event_token GotFocus(TypedEventHandler<InputFocusController, FocusChangedEventArgs const&> const& handler) const;

// Revoke with event_token
void GotFocus(event_token const* cookie) const;

// Revoke with event_revoker
InputFocusController::GotFocus_revoker GotFocus(auto_revoke_t, TypedEventHandler<InputFocusController, FocusChangedEventArgs const&> const& handler) const;
public event TypedEventHandler<InputFocusController,FocusChangedEventArgs> GotFocus;
function onGotFocus(eventArgs) { /* Your code */ }
inputFocusController.addEventListener("gotfocus", onGotFocus);
inputFocusController.removeEventListener("gotfocus", onGotFocus);
- or -
inputFocusController.ongotfocus = onGotFocus;
Public Custom Event GotFocus As TypedEventHandler(Of InputFocusController, FocusChangedEventArgs) 

事件类型

注解

ContentIsland 可以通过 TrySetFocus 方法接收焦点,或者因为焦点是从其他位置移动的。 例如,使用 DesktopChildSiteBridge 托管内容的应用应通过在网桥的 HWND 上调用 SetFocus 来指示焦点是移动到内容。 然后,在内部,桥会将焦点移动到 ContentIsland 的基础 HWND,并且将引发 GotFocus 事件。

注意

如果应用的顶级 HWND 具有焦点并变为非活动状态,则焦点将丢失,并且不会在 HWND 再次处于活动状态后回退。 相反,焦点将设置为已激活的顶级窗口,HWND 不会引发 GotFocus 事件 (例如,如果用户 Alt+Tab 导航回应用) 。

在这种情况下,需要手动将焦点设置为 ContentIslandInputActivationListener 支持可帮助确定窗口激活时间的事件。

适用于

另请参阅