inputmethod_text_config_capi.h

Overview

Provides methods for creating, destroying, reading, and writing the text box configuration information objects.

File to include: <inputmethod/inputmethod_text_config_capi.h>

Library: libohinputmethod.so

System capability: SystemCapability.MiscServices.InputMethodFramework

Since: 12

Related module: InputMethod

Summary

Structs

Name typedef Keyword Description
InputMethod_TextConfig InputMethod_TextConfig Text box configuration.

Function

Name Description
InputMethod_TextConfig *OH_TextConfig_Create(void) Creates an InputMethod_TextConfig instance.
void OH_TextConfig_Destroy(InputMethod_TextConfig *config) Destroys an InputMethod_TextConfig instance.
InputMethod_ErrorCode OH_TextConfig_SetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType inputType) Sets the text box type.
InputMethod_ErrorCode OH_TextConfig_SetEnterKeyType(InputMethod_TextConfig *config, InputMethod_EnterKeyType enterKeyType) Sets the Enter key type.
InputMethod_ErrorCode OH_TextConfig_SetPreviewTextSupport(InputMethod_TextConfig *config, bool supported) Sets the text preview feature.
InputMethod_ErrorCode OH_TextConfig_SetSelection(InputMethod_TextConfig *config, int32_t start, int32_t end) Sets the selected text area.
InputMethod_ErrorCode OH_TextConfig_SetWindowId(InputMethod_TextConfig *config, int32_t windowId) Sets the window ID.
InputMethod_ErrorCode OH_TextConfig_SetPlaceholder(InputMethod_TextConfig *config, const char16_t *placeholder,size_t length) Sets the placeholder text.
InputMethod_ErrorCode OH_TextConfig_SetAbilityName(InputMethod_TextConfig *config, const char16_t *abilityName,size_t length) Sets the ability name.
InputMethod_ErrorCode OH_TextConfig_GetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType *inputType) Obtains the text box type.
InputMethod_ErrorCode OH_TextConfig_GetEnterKeyType(InputMethod_TextConfig *config, InputMethod_EnterKeyType *enterKeyType) Obtains the Enter key type.
InputMethod_ErrorCode OH_TextConfig_IsPreviewTextSupported(InputMethod_TextConfig *config, bool *supported) Obtains whether the text preview feature is supported.
InputMethod_ErrorCode OH_TextConfig_GetCursorInfo(InputMethod_TextConfig *config, InputMethod_CursorInfo **cursorInfo) Obtains the cursor information.
InputMethod_ErrorCode OH_TextConfig_GetTextAvoidInfo(InputMethod_TextConfig *config, InputMethod_TextAvoidInfo **avoidInfo) Obtains the avoidance information.
InputMethod_ErrorCode OH_TextConfig_GetSelection(InputMethod_TextConfig *config, int32_t *start, int32_t *end) Obtains the selected text area.
InputMethod_ErrorCode OH_TextConfig_GetWindowId(InputMethod_TextConfig *config, int32_t *windowId) Obtains the window ID.
InputMethod_ErrorCode OH_TextConfig_GetPlaceholder(InputMethod_TextConfig *config, char16_t *placeholder,size_t *length) Obtains the placeholder text.
InputMethod_ErrorCode OH_TextConfig_GetAbilityName(InputMethod_TextConfig *config, char16_t *abilityName,size_t *length) Obtains the ability name.

Function Description

OH_TextConfig_Create()

InputMethod_TextConfig *OH_TextConfig_Create(void)

Description

Creates an InputMethod_TextConfig instance.

Since: 12

Returns

Type Description
InputMethod_TextConfig * If the operation is successful, a pointer to the created InputMethod_TextConfig instance is returned.
If the operation failed, NULL is returned, which may be caused by insufficient application address space.

OH_TextConfig_Destroy()

void OH_TextConfig_Destroy(InputMethod_TextConfig *config)

Description

Destroys an InputMethod_TextConfig instance.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance to be destroyed.

OH_TextConfig_SetInputType()

InputMethod_ErrorCode OH_TextConfig_SetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType inputType)

Description

Sets the text box type.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be set.
InputMethod_TextInputType inputType Input type of the text box.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_SetEnterKeyType()

InputMethod_ErrorCode OH_TextConfig_SetEnterKeyType(InputMethod_TextConfig *config, InputMethod_EnterKeyType enterKeyType)

Description

Sets the Enter key type.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be set.
InputMethod_EnterKeyType enterKeyType Enter key type.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_SetPreviewTextSupport()

InputMethod_ErrorCode OH_TextConfig_SetPreviewTextSupport(InputMethod_TextConfig *config, bool supported)

Description

Sets the text preview feature.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be set.
bool supported Whether text preview is supported. true: Text preview is supported. false: Text preview is not supported.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_SetSelection()

InputMethod_ErrorCode OH_TextConfig_SetSelection(InputMethod_TextConfig *config, int32_t start, int32_t end)

Description

Sets the selected text area.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be set.
int32_t start Start position of the selected text.
int32_t end End position of the selected text.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_SetWindowId()

InputMethod_ErrorCode OH_TextConfig_SetWindowId(InputMethod_TextConfig *config, int32_t windowId)

Description

Sets the window ID.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be set.
int32_t windowId Window ID of the application bound to the input method.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_SetPlaceholder()

InputMethod_ErrorCode OH_TextConfig_SetPlaceholder(InputMethod_TextConfig *config, const char16_t *placeholder,size_t length)

Description

Sets the placeholder text.

Since: 20

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be set.
const char16_t *placeholder Pointer to a UTF-16 encoded double-byte string. If a null pointer is passed, the placeholder text is an empty string.
size_t length Number of elements in the memory to which placeholder points, including the null character of the double-byte string.1. If length is 0, the placeholder text is an empty string.2. The maximum length of UTF-16 encoding is 255 characters (the null character of the string is not included in the count). If the length exceeds 255 characters, the extra characters will be truncated.

Returns

Type Description
InputMethod_ErrorCode InputMethod_ErrorCode:
IME_ERR_OK = 0: indicates success.
IME_ERR_NULL_POINTER = 12802000: indicates an unexpected null pointer.

OH_TextConfig_SetAbilityName()

InputMethod_ErrorCode OH_TextConfig_SetAbilityName(InputMethod_TextConfig *config, const char16_t *abilityName,size_t length)

Description

Sets the ability name.

Since: 20

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be set.
const char16_t *abilityName Pointer to a UTF-16 encoded double-byte string. If a null pointer is passed, the ability name is an empty string.
size_t length Number of elements in the memory to which abilityName points, including the null character of the double-byte string.1. If length is 0, the ability name is set to an empty string.2. The maximum length of UTF-16 encoding is 127 characters (the null character of the string is not included in the count). If the length exceeds 127 characters, the extra characters will be truncated.

Returns

Type Description
InputMethod_ErrorCode InputMethod_ErrorCode:
IME_ERR_OK = 0: indicates success.
IME_ERR_NULL_POINTER = 12802000: indicates an unexpected null pointer.

OH_TextConfig_GetInputType()

InputMethod_ErrorCode OH_TextConfig_GetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType *inputType)

Description

Obtains the text box type.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be obtained.
InputMethod_TextInputType *inputType Pointer to the InputMethod_TextInputType instance. Input type of the text box.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_GetEnterKeyType()

InputMethod_ErrorCode OH_TextConfig_GetEnterKeyType(InputMethod_TextConfig *config, InputMethod_EnterKeyType *enterKeyType)

Description

Obtains the Enter key type.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be obtained.
InputMethod_EnterKeyType *enterKeyType Pointer to the InputMethod_EnterKeyType instance. Enter key type of the text box.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_IsPreviewTextSupported()

InputMethod_ErrorCode OH_TextConfig_IsPreviewTextSupported(InputMethod_TextConfig *config, bool *supported)

Description

Obtains whether the text preview feature is supported.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be obtained.
bool *supported Whether text preview is supported. true: Text preview is supported. false: Text preview is not supported.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_GetCursorInfo()

InputMethod_ErrorCode OH_TextConfig_GetCursorInfo(InputMethod_TextConfig *config, InputMethod_CursorInfo **cursorInfo)

Description

Obtains the cursor information.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be obtained.
InputMethod_CursorInfo **cursorInfo Cursor information.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_GetTextAvoidInfo()

InputMethod_ErrorCode OH_TextConfig_GetTextAvoidInfo(InputMethod_TextConfig *config, InputMethod_TextAvoidInfo **avoidInfo)

Description

Obtains the avoidance information.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Text configuration information.
InputMethod_TextAvoidInfo **avoidInfo Text box avoidance information.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_GetSelection()

InputMethod_ErrorCode OH_TextConfig_GetSelection(InputMethod_TextConfig *config, int32_t *start, int32_t *end)

Description

Obtains the selected text area.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be obtained.
int32_t *start Start position of the selected text.
int32_t *end End position of the selected text.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_GetWindowId()

InputMethod_ErrorCode OH_TextConfig_GetWindowId(InputMethod_TextConfig *config, int32_t *windowId)

Description

Obtains the window ID.

Since: 12

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be obtained.
int32_t *windowId Window ID of the application bound to the input method.

Returns

Type Description
InputMethod_ErrorCode An error code.
IME_ERR_OK - Success.
IME_ERR_NULL_POINTER - An unexpected null pointer.
For details about the error codes, see InputMethod_ErrorCode.

OH_TextConfig_GetPlaceholder()

InputMethod_ErrorCode OH_TextConfig_GetPlaceholder(InputMethod_TextConfig *config, char16_t *placeholder,size_t *length)

Description

Obtains the placeholder text.

Since: 20

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be obtained.
char16_t *placeholder Pointer to the placeholder text. The memory of this pointer is maintained by the caller.
size_t *length Pointer to the length of the placeholder text, in double bytes. The length includes the null character of the string.1. As an input parameter, length indicates the available length of the memory to which placeholder points. As an output parameter, it indicates the actual length of the placeholder text.2. If placeholder is a null pointer and length points to valid memory, length will be set to the actual length of the placeholder text, and an error will be thrown.3. If both placeholder and length point to valid memory, but the value of length is less than the actual length of the placeholder text, length will be set to the actual length of the placeholder text, and an error will be thrown.

Returns

Type Description
InputMethod_ErrorCode InputMethod_ErrorCode:
IME_ERR_OK = 0: indicates success.
IME_ERR_PARAMCHECK = 401: indicates that parameter check failed.
IME_ERR_NULL_POINTER = 12802000: indicates an unexpected null pointer.

OH_TextConfig_GetAbilityName()

InputMethod_ErrorCode OH_TextConfig_GetAbilityName(InputMethod_TextConfig *config, char16_t *abilityName,size_t *length)

Description

Obtains the ability name.

Since: 20

Parameters

Name Description
InputMethod_TextConfig *config Pointer to the InputMethod_TextConfig instance whose value is to be obtained.
char16_t *abilityName Pointer to the ability name. The memory of this pointer is maintained by the caller.
size_t *length Pointer to the length of the ability name, in double bytes. The length includes the null character of the string.1. As an input parameter, length indicates the available length of the memory to which abilityName points. As an output parameter, it indicates the actual length of the ability name.2. If abilityName is a null pointer and length points to valid memory, length will be set to the actual length of the ability name, and an error will be thrown.3. If both abilityName and length point to valid memory, but the value of length is less than the actual length of the ability name, length will be set to the actual length of the ability name, and an error will be thrown.

Returns

Type Description
InputMethod_ErrorCode InputMethod_ErrorCode:
IME_ERR_OK = 0: indicates success.
IME_ERR_PARAMCHECK = 401: indicates that parameter check failed.
IME_ERR_NULL_POINTER = 12802000: indicates an unexpected null pointer.