From 0d9f8bb3613f62d5c673f19decc7da5f8e7f4779 Mon Sep 17 00:00:00 2001 From: zhaolinglan Date: Tue, 23 Aug 2022 20:58:46 +0800 Subject: [PATCH] add api description Signed-off-by: zhaolinglan --- .../apis/js-apis-inputmethodengine.md | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index afc2717799..dc377ed9f4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -45,6 +45,11 @@ import inputMethodEngine from '@ohos.inputmethodengine'; | FLAG_SINGLE_LINE | number | 是 | 否 | 编辑框为单行。 | | DISPLAY_MODE_PART | number | 是 | 否 | 编辑框显示为半屏。 | | DISPLAY_MODE_FULL | number | 是 | 否 | 编辑框显示为全屏。 | +| CURSOR_UP | number | 是 | 否 | 光标上移 | +| CURSOR_DOWN | number | 是 | 否 | 光标下移 | +| CURSOR_LEFT | number | 是 | 否 | 光标左移 | +| CURSOR_RIGHT | number | 是 | 否 | 光标右移 | +| WINDOW_TYPE_INPUT_METHOD_FLOAT | number | 是 | 否 | 输入法应用窗口风格标识 | ## inputMethodEngine.getInputMethodEngine @@ -139,6 +144,98 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC }); ``` +### on('inputStop')9+ + +on(type: 'inputStop', callback: () => void): void + +订阅停止输入法应用事件,使用callback回调返回输入法操作相关实例。 + +**系统能力**: SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 设置监听类型。
-type为‘inputStop’时表示订阅停止输入法应用。 | +| callback | void | 是 | 回调函数。 | + +**示例:** + + ```js +InputMethodEngine.getInputMethodEngine().on('inputStop', () => { + console.log("inputMethodEngine inputStop"); +}); + ``` + +### off('inputStop')9+ + +off(type: 'inputStop', callback: () => void): void + +取消订阅停止输入法应用事件。使用callback回调返回输入法操作相关实例。 + +**系统能力**: SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ----------------------------------------------------------- | +| type | string | 是 | 设置监听类型。
-type为‘inputStop’时表示订阅输入法绑定。 | +| callback | void | 是 | 回调返回输入法操作相关实例。 | + +**示例:** + + ```js +InputMethodEngine.getInputMethodEngine().off('inputStop', () => { + console.log("delete inputStop notification."); +}); + ``` + +### on('setCallingWindow')9+ + +on(type: 'setCallingWindow', callback: (wid:number) => void): void + +订阅设置调用窗口事件,使用callback回调。 + +**系统能力**: SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 设置监听类型。
-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 | +| wid | number | 是 | 调用方window id。 | + +**示例:** + + ```js +InputMethodEngine.getInputMethodEngine().on('setCallingWindow', (wid) => { + console.log("inputMethodEngine setCallingWindow"); +}); + ``` + +### off('setCallingWindow')9+ + +off(type: 'setCallingWindow', callback: (wid:number) => void): void + +取消订设置调用窗口事件。使用callback回调。 + +**系统能力**: SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 设置监听类型。
-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 | +| callback | number | 是 | 调用方window id。 | + +**示例:** + + ```js +InputMethodEngine.getInputMethodEngine().off('setCallingWindow', () => { + console.log("delete setCallingWindow notification."); +}); + ``` + ### on('keyboardShow'|'keyboardHide') on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void @@ -908,6 +1005,64 @@ getEditorAttribute(): Promise } ``` +### moveCursor9+ + +moveCursor(direction: number, callback: AsyncCallback<void>): void + +移动光标。使用callback形式返回结果。参数个数为1,否则抛出异常。 + +**系统能力**: SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | -------------- | +| direction | number | 是 | 光标移动方向。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +```js +TextInputClient.moveCursor(inputMethodEngine.CURSOR_xxx, (err) => { + if (err == undefined) { + console.error("moveCursor callback result---err: " + err.msg); + return; + } +}); +``` + +### moveCursor9+ + +moveCursor(direction: number): Promise<void> + +移动光标。使用promise形式返回结果。参数个数为1,否则抛出异常。 + +**系统能力**: SystemCapability.MiscServices.InputMethodFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | -------------- | +| direction | string | 是 | 光标移动方向。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | + +**示例:** + + ```js +async function InputMethodEngine() { + await TextInputClient.moveCursor('test').then(async (err) => { + console.log('moveCursor success'); + }).catch((err) => { + console.error("moveCursor success err: " + err.msg); + }); +} + ``` + ## EditorAttribute 编辑框属性值。 -- GitLab