openharmony 鸿蒙 capi-inputmethod-text-config-capi-h

2026-08-25 浏览 (1)

inputmethod_text_config_capi.h

概述

提供输入框配置信息对象的创建、销毁与读写方法。

引用文件: <inputmethod/inputmethod_text_config_capi.h>

库: libohinputmethod.so

系统能力: SystemCapability.MiscServices.InputMethodFramework

起始版本: 12

相关模块: InputMethod

汇总

结构体

名称typedef关键字描述
InputMethod_TextConfigInputMethod_TextConfig输入框的配置信息。

函数

名称描述
InputMethod_TextConfig *OH_TextConfig_Create(void)创建一个新的InputMethod_TextConfig实例。
void OH_TextConfig_Destroy(InputMethod_TextConfig *config)销毁一个InputMethod_TextConfig实例。
InputMethod_ErrorCode OH_TextConfig_SetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType inputType)设置文本配置信息中的输入框类型。
InputMethod_ErrorCode OH_TextConfig_SetEnterKeyType(InputMethod_TextConfig *config, InputMethod_EnterKeyType enterKeyType)设置文本配置信息中的回车键功能类型。
InputMethod_ErrorCode OH_TextConfig_SetPreviewTextSupport(InputMethod_TextConfig *config, bool supported)将预上屏支持情况设置到文本配置信息中。
InputMethod_ErrorCode OH_TextConfig_SetSelection(InputMethod_TextConfig *config, int32_t start, int32_t end)设置文本配置信息中的选中文本范围。
InputMethod_ErrorCode OH_TextConfig_SetWindowId(InputMethod_TextConfig *config, int32_t windowId)设置文本配置信息中所属窗口的窗口id。
InputMethod_ErrorCode OH_TextConfig_SetPlaceholder(InputMethod_TextConfig *config, const char16_t *placeholder,size_t length)设置文本配置信息中的占位符文本信息。
InputMethod_ErrorCode OH_TextConfig_SetAbilityName(InputMethod_TextConfig *config, const char16_t *abilityName,size_t length)设置文本配置信息中的abilityName信息。
InputMethod_ErrorCode OH_TextConfig_GetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType *inputType)获取文本配置信息中的输入框类型。
InputMethod_ErrorCode OH_TextConfig_GetEnterKeyType(InputMethod_TextConfig *config, InputMethod_EnterKeyType *enterKeyType)获取文本配置信息中的回车键功能类型。
InputMethod_ErrorCode OH_TextConfig_IsPreviewTextSupported(InputMethod_TextConfig *config, bool *supported)获取文本配置中是否支持预上屏。
InputMethod_ErrorCode OH_TextConfig_GetCursorInfo(InputMethod_TextConfig *config, InputMethod_CursorInfo **cursorInfo)获取文本配置信息中的光标信息。
InputMethod_ErrorCode OH_TextConfig_GetTextAvoidInfo(InputMethod_TextConfig *config, InputMethod_TextAvoidInfo **avoidInfo)获取文本配置信息中的避让信息。
InputMethod_ErrorCode OH_TextConfig_GetSelection(InputMethod_TextConfig *config, int32_t *start, int32_t *end)获取文本配置信息中的选区范围信息。
InputMethod_ErrorCode OH_TextConfig_GetWindowId(InputMethod_TextConfig *config, int32_t *windowId)获取文本配置信息中所属窗口的窗口id。
InputMethod_ErrorCode OH_TextConfig_GetPlaceholder(InputMethod_TextConfig *config, char16_t *placeholder,size_t *length)获取文本配置信息中的占位符文本信息。
InputMethod_ErrorCode OH_TextConfig_GetAbilityName(InputMethod_TextConfig *config, char16_t *abilityName,size_t *length)获取文本配置信息中的abilityName信息。

函数说明

OH_TextConfig_Create()

InputMethod_TextConfig *OH_TextConfig_Create(void)

描述

创建一个新的InputMethod_TextConfig实例。

起始版本: 12

返回:

类型说明
InputMethod_TextConfig *如果创建成功,返回一个指向新创建的InputMethod_TextConfig实例的指针。
如果创建失败,对象返回NULL,可能的失败原因有应用地址空间满。

OH_TextConfig_Destroy()

void OH_TextConfig_Destroy(InputMethod_TextConfig *config)

描述

销毁一个InputMethod_TextConfig实例。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config表示指向即将被销毁的InputMethod_TextConfig实例的指针。

OH_TextConfig_SetInputType()

InputMethod_ErrorCode OH_TextConfig_SetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType inputType)

描述

设置文本配置信息中的输入框类型。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被设置值的InputMethod_TextConfig实例的指针。
InputMethod_TextInputType inputType输入框的输入类型。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_SetEnterKeyType()

InputMethod_ErrorCode OH_TextConfig_SetEnterKeyType(InputMethod_TextConfig *config, InputMethod_EnterKeyType enterKeyType)

描述

设置文本配置信息中的回车键功能类型。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被设置值的InputMethod_TextConfig实例的指针。
InputMethod_EnterKeyType enterKeyType回车键功能类型。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_SetPreviewTextSupport()

InputMethod_ErrorCode OH_TextConfig_SetPreviewTextSupport(InputMethod_TextConfig *config, bool supported)

描述

将预上屏支持情况设置到文本配置信息中。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被设置值的InputMethod_TextConfig实例的指针。
bool supported表示输入框是否支持预上屏。true - 表示支持预上屏。false - 表示不支持预上屏。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_SetSelection()

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

描述

设置文本配置信息中的选中文本范围。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被设置值的InputMethod_TextConfig实例的指针。
int32_t start所选文本的起始位置。
int32_t end所选文本的结束位置。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_SetWindowId()

InputMethod_ErrorCode OH_TextConfig_SetWindowId(InputMethod_TextConfig *config, int32_t windowId)

描述

设置文本配置信息中所属窗口的窗口id。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被设置值的InputMethod_TextConfig实例的指针。
int32_t windowId绑定输入法的应用所属窗口的窗口id。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_SetPlaceholder()

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

描述

设置文本配置信息中的占位符文本信息。

起始版本: 20

参数:

参数项描述
InputMethod_TextConfig *config指向即将被设置值的InputMethod_TextConfig实例的指针。
const char16_t *placeholder指向UTF-16编码的双字节指针;若传空指针,则会将占位文本信息设置为空字符串。
size_t lengthplaceholder指针指向内存所包含的元素个数,包含最后的字符串结尾符,计数单位为双字节。1. 如果长度为0,占位文本信息会被设置为空字符串。2. UTF-16编码的最大长度为255个字符(如果最后一位是字符串结尾符,不包含在计数中),超过255个字符数将会被截断。

返回:

类型说明
InputMethod_ErrorCodeInputMethod_ErrorCode
IME_ERR_OK = 0:表示成功。
IME_ERR_NULL_POINTER = 12802000:非预期的空指针。

OH_TextConfig_SetAbilityName()

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

描述

设置文本配置信息中的abilityName信息。

起始版本: 20

参数:

参数项描述
InputMethod_TextConfig *config指向即将被设置值的InputMethod_TextConfig实例的指针。
const char16_t *abilityName指向UTF-16编码的双字节指针;若传空指针,则会将abilityName设置为空字符串。
size_t lengthabilityName指针指向内存所包含的元素个数,包含最后的字符串结尾符,计数单位为双字节。1. 如果长度为0,abilityName会被设置为空字符串。2. UTF-16编码的最大长度为127个字符(如果最后一位是字符串结尾符,不包含在计数中),超过127个字符数将会被截断。

返回:

类型说明
InputMethod_ErrorCodeInputMethod_ErrorCode
IME_ERR_OK = 0:表示成功。
IME_ERR_NULL_POINTER = 12802000:非预期的空指针。

OH_TextConfig_GetInputType()

InputMethod_ErrorCode OH_TextConfig_GetInputType(InputMethod_TextConfig *config, InputMethod_TextInputType *inputType)

描述

获取文本配置信息中的输入框类型。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被获取值的InputMethod_TextConfig实例的指针。
InputMethod_TextInputType *inputType表示指向InputMethod_TextInputType实例的指针。 输入框的输入类型。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_GetEnterKeyType()

InputMethod_ErrorCode OH_TextConfig_GetEnterKeyType(InputMethod_TextConfig *config, InputMethod_EnterKeyType *enterKeyType)

描述

获取文本配置信息中的回车键功能类型。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被获取值的InputMethod_TextConfig实例的指针。
InputMethod_EnterKeyType *enterKeyType表示指向InputMethod_EnterKeyType实例的指针。 输入框的回车键功能类型。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_IsPreviewTextSupported()

InputMethod_ErrorCode OH_TextConfig_IsPreviewTextSupported(InputMethod_TextConfig *config, bool *supported)

描述

获取文本配置中是否支持预上屏。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被获取值的InputMethod_TextConfig实例的指针。
bool *supported表示输入框是否支持预上屏。true - 表示支持预上屏。false - 表示不支持预上屏。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_GetCursorInfo()

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

描述

获取文本配置信息中的光标信息。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被获取值的InputMethod_TextConfig实例的指针。
InputMethod_CursorInfo **cursorInfo光标信息。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_GetTextAvoidInfo()

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

描述

获取文本配置信息中的避让信息。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config表示文本配置信息。
InputMethod_TextAvoidInfo **avoidInfo输入框避让信息。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_GetSelection()

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

描述

获取文本配置信息中的选区范围信息。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被获取值的InputMethod_TextConfig实例的指针。
int32_t *start所选文本的起始位置。
int32_t *end所选文本的结束位置。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_GetWindowId()

InputMethod_ErrorCode OH_TextConfig_GetWindowId(InputMethod_TextConfig *config, int32_t *windowId)

描述

获取文本配置信息中所属窗口的窗口id。

起始版本: 12

参数:

参数项描述
InputMethod_TextConfig *config指向即将被获取值的InputMethod_TextConfig实例的指针。
int32_t *windowId绑定输入法的应用所属窗口的窗口id。

返回:

类型说明
InputMethod_ErrorCode返回一个特定的错误码。
IME_ERR_OK - 表示成功。
IME_ERR_NULL_POINTER - 非预期的空指针。
具体错误码可以参考InputMethod_ErrorCode

OH_TextConfig_GetPlaceholder()

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

描述

获取文本配置信息中的占位符文本信息。

起始版本: 20

参数:

参数项描述
InputMethod_TextConfig *config指向即将被获取值的InputMethod_TextConfig实例的指针。
char16_t *placeholder用于存放占位文本信息,该指针内存由调用者维护。
size_t *length占位文本信息长度,计数单位为双字节,长度包含字符串结尾符。1. 作为入参,代表placeholder指向的内存可用长度。作为出参,代表实际的占位文本长度。2. 如果placeholder为空指针,且length指向有效内存,则length会被填充实际的占位文本长度。接口会返错。3. 如果placeholder和length都指向有效内存,但length传入的长度小于实际的占位文本长度,则length会被填充实际的占位文本长度。接口会返错。

返回:

类型说明
InputMethod_ErrorCodeInputMethod_ErrorCode
IME_ERR_OK = 0:表示成功。
IME_ERR_PARAMCHECK = 401:参数检查失败。
IME_ERR_NULL_POINTER = 12802000:非预期的空指针。

OH_TextConfig_GetAbilityName()

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

描述

获取文本配置信息中的abilityName信息。

起始版本: 20

参数:

参数项描述
InputMethod_TextConfig *config指向即将被获取值的InputMethod_TextConfig实例的指针。
char16_t *abilityName用于存放abilityName,该指针内存由调用者维护。
size_t *lengthabilityName长度,计数单位为双字节,长度包含字符串结尾符。1. 作为入参,代表abilityName指向的内存可用长度。作为出参,代表实际的abilityName长度。2. 如果abilityName为空指针,且length指向有效内存,则length会被填充实际的abilityName长度。接口会返错。3. 如果abilityName和length都指向有效内存,但length传入的长度小于实际的abilityName长度,则length会被填充实际的abilityName长度。接口会返错。

返回:

类型说明
InputMethod_ErrorCodeInputMethod_ErrorCode
IME_ERR_OK = 0:表示成功。
IME_ERR_PARAMCHECK = 401:参数检查失败。
IME_ERR_NULL_POINTER = 12802000:非预期的空指针。

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-inputmethod-inputmethod-textconfig

openharmony 鸿蒙 js-apis-inputmethod-extension-context

openharmony 鸿蒙 js-apis-inputmethod-subtype

openharmony 鸿蒙 capi-inputmethod-inputmethod-proxy-capi-h

openharmony 鸿蒙 capi-inputmethod-text-editor-proxy-capi-h

openharmony 鸿蒙 capi-inputmethod-controller-capi-h

openharmony 鸿蒙 capi-inputmethod

openharmony 鸿蒙 js-apis-inputmethod-panel

openharmony 鸿蒙 js-apis-inputmethodengine

openharmony 鸿蒙 capi-inputmethod-cursor-info-capi-h

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/w0gYX4Lx