typedef struct InputMethod_PrivateCommand InputMethod_PrivateCommand
Represents a private command struct adopting the key-value mechanism. It serves as a carrier for transmitting private data between the text input box and the input method app. It can be used to deliver custom commands, extended capability parameters, and scenario-specific data, improving the extensibility and compatibility of input method features. Each PrivateCommand instance contains a key (identifier string) and a value (boolean, integer or string; only one type can be selected). The data type of the value is indicated by InputMethod_CommandValueType.
Purpose: Transmits private data between the input method app and the edit box client to enable custom communication between the two sides. The input method app sends private commands to the edit box client via OH_InputMethodProxy_SendPrivateCommand. The edit box client receives private commands from the input method app through the OH_TextEditorProxy_ReceivePrivateCommandFunc callback. Each PrivateCommand instance carries one piece of key-value private data. Up to five instances can be sent in a single transmission. The total size of all private data and key values in one transmission is limited to 32 KB.
Usage scenarios:
The input method app sends private commands to the edit box: The input method app creates a PrivateCommand instance and sends it to the edit box client via OH_InputMethodProxy_SendPrivateCommand with the key and value set.
The edit box client receives private commands: The edit box client receives an array of PrivateCommand instances from the input method app through the OH_TextEditorProxy_ReceivePrivateCommandFunc callback, and traverses the array to parse the key and value of each instance.
Since: 12
Related module: InputMethod
Header file: inputmethod_private_command_capi.h
Related functions
| Function | Description |
|---|---|
| OH_PrivateCommand_Create | Creates an InputMethod_PrivateCommand instance. |
| OH_PrivateCommand_Destroy | Destroys an InputMethod_PrivateCommand instance. |
| OH_PrivateCommand_SetKey | Sets the key value. |
| OH_PrivateCommand_SetBoolValue | Sets the boolean-type value. |
| OH_PrivateCommand_SetIntValue | Sets the integer-type value. |
| OH_PrivateCommand_SetStrValue | Sets the string-type value. |
| OH_PrivateCommand_GetKey | Obtains the key value. |
| OH_PrivateCommand_GetValueType | Obtains the data type of the value. |
| OH_PrivateCommand_GetBoolValue | Obtains the boolean-type value. |
| OH_PrivateCommand_GetIntValue | Obtains the integer-type value. |
| OH_PrivateCommand_GetStrValue | Obtains the string-type value. |
Related APIs:
| API | Description |
|---|---|
| OH_InputMethodProxy_SendPrivateCommand | Sends private commands from the input method app to the edit box client. An array of PrivateCommand instances is passed as a parameter. Up to five instances are allowed, and the total size of data is limited to 32 KB. |
| OH_TextEditorProxy_ReceivePrivateCommandFunc | Callback API for the edit box client to receive private commands. An array of PrivateCommand instances is passed as a parameter. Memory for the instances is released after the callback returns. |
Related Enums
| Enum | Description |
|---|---|
| InputMethod_CommandValueType | Enumerates the data types of the value in PrivateCommand (NONE/STRING/BOOL/INT32). |