Share via


InputFocusController Class

Definition

Represents an object that supports the handling and management of focus events on a ContentIsland.

public ref class InputFocusController sealed : InputObject
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65540)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class InputFocusController final : InputObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65540)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InputFocusController : InputObject
Public NotInheritable Class InputFocusController
Inherits InputObject
Inheritance
Object Platform::Object IInspectable InputObject InputFocusController
Attributes

Remarks

A ContentIsland has an underlying HWND that can interact with Win32 APIs and receive Win32 messages (such as various input messages).

A ContentIsland has focus if its underlying HWND has Win32 focus.

When A ContentIsland has focus, it will receive keyboard input messages from the system. Keyboard input events can be handled by an InputKeyboardSource object, which is retrieved through the InputKeyboardSource.GetForIsland(Microsoft.UI.Content.ContentIsland) method.

Note

For more details about Win32 focus and keyboard input see the Keyboard Focus and Activation section of the Keyboard Input Overview.

Behavior when disposed

An InputFocusController is associated with a specific ContentIsland. If the InputFocusController is disposed then it loses that association and all event handlers are unregistered.

If the associated ContentIsland is disposed, then the associated InputFocusController is also disposed.

For more details, see Microsoft.UI.Input.InputObject.

Threading model

An InputFocusController can only be from the thread where it was created. Any property access or function call on a different thread will return RPC_E_WRONG_THREAD (or the equivalent projected error type).

For more details, see Microsoft.UI.Input.InputObject.

Properties

DispatcherQueue

Gets the DispatcherQueue for the InputObject.

(Inherited from InputObject)
HasFocus

Gets whether the associated ContentIsland has focus.

Methods

DepartFocus(FocusNavigationRequest)

Raises the InputFocusNavigationHost.DepartFocusRequested event for the Content.ContentIsland host.

For example, the user has tabbed through all of the tabbable elements within the ContentIsland and now focus should move away from the Island to something else in the hosting application.

GetForIsland(ContentIsland)

Retrieves an InputFocusController object for the specified ContentIsland.

TrySetFocus()

Attempts to set focus to the ContentIsland associated with the InputFocusController.

Events

GotFocus

Occurs when the associated ContentIsland receives focus.

LostFocus

Occurs when focus is moved from the associated ContentIsland.

NavigateFocusRequested

Occurs when the Content.ContentIsland host wants the ContentIsland to take focus.

For example, the user has tabbed through the elements of the host and now needs to tab into the ContentIsland. The hosting application calls InputFocusNavigationHost.NavigateFocus(Microsoft.UI.Input.FocusNavigationRequest) on the InputFocusNavigationHost associated with the SiteBridge. The InputFocusController for the ContentIsland then receives this NavigateFocusRequested event and can decide if it will take focus.

Applies to

See also