Share via


InputFocusController.GotFocus Event

Definition

Occurs when the associated ContentIsland receives focus.

// 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) 

Event Type

Remarks

A ContentIsland can receive focus through the TrySetFocus method, or because focus is moved from elsewhere. For example, an app using a DesktopChildSiteBridge to host content should signal that focus is to move to the content by calling SetFocus on the HWND of the bridge. The bridge internally will then move focus to the underlying HWND of the ContentIsland and the GotFocus event will be raised.

Note

If the top-level HWND of an app has focus and becomes inactive, focus will be lost and will not set back once the HWND is active again. Instead focus will be set to the top-level window that was activated and the HWND will not raise the GotFocus event (for example, if the user Alt+Tab navigates back to the app).

In this case, you need to manually set focus to the ContentIsland. The InputActivationListener supports events that can help determine when a window has been activated.

Applies to

See also