typedef struct InputMethod_AttachOptions InputMethod_AttachOptions
InputMethod_AttachOptions is an opaque type for input method attachment options. It carries configuration parameters when an app attaches to the input method service and controls the initial behavior during attachment.
Purpose: It serves as a mandatory parameter for OH_InputMethodController_Attach and OH_InputMethodController_AttachWithUIContext, used to configure behavior options for input method attachment, including:
Whether to automatically show the keyboard upon attachment (showKeyboard): Controls whether the keyboard pops up immediately after attachment completes.
Reason for requesting the keyboard (requestKeyboardReason): Identifies the scenario that triggers the input method activation (such as a tap, mouse click, or active app invocation), helping the system optimize the input experience.
Usage scenarios:
showKeyboard=true: Applies to scenarios requiring immediate input after an input box gains focus (e.g., text input box). The keyboard pops up automatically after attachment.
showKeyboard=false: Applies to scenarios where an interaction channel is established first but the keyboard is not needed immediately (e.g., search box). No keyboard appears after attachment; the keyboard can be activated later via ShowKeyboard.
requestKeyboardReason: Applies to scenarios where the app needs to inform the system of the trigger reason for input method activation, enabling the system to adopt an appropriate input strategy.
Related functions
| Function | Description |
|---|---|
| OH_AttachOptions_Create | Creates an AttachOptions instance. |
| OH_AttachOptions_CreateWithRequestKeyboardReason | Creates an AttachOptions instance and specifies the requestKeyboardReason. |
| OH_AttachOptions_Destroy | Destroys an AttachOptions instance. |
| OH_AttachOptions_IsShowKeyboard | Obtains the showKeyboard value. |
| OH_AttachOptions_GetRequestKeyboardReason | Obtains the requestKeyboardReason value. |
Relationship with other structs:
InputMethod_AttachOptions is one of the mandatory parameters of OH_InputMethodController_Attach and OH_InputMethodController_AttachWithUIContext. This attach function requires both InputMethod_TextEditorProxy and InputMethod_AttachOptions.
The requestKeyboardReason member in InputMethod_AttachOptions adopts the InputMethod_RequestKeyboardReason enumeration type which is defined in inputmethod_types_capi.h.
OH_InputMethodProxy_ShowTextInput also accepts InputMethod_AttachOptions as a parameter, for requesting to show the keyboard again under an attached state and specifying the request reason.
Since: 12
Related module: InputMethod
Header file: inputmethod_attach_options_capi.h