提交 fc7c5062 编写于 作者: H Hollokin

输入法框架API资料修改

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 01291ea5
......@@ -68,124 +68,3 @@ class InputMethodExt extends InputMethodExtensionAbility {
}
}
```
## InputMethodExtensionAbility.onRequest()
onRequest(want: Want, startId: number): void
Extension生命周期回调,在一个输入法extention开始时回调,执行输入法的相关操作。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
| startId | number | 是 | 返回拉起次数。首次拉起初始值返回1,多次之后自动递增。 |
**示例:**
```ts
class InputMethodExt extends InputMethodExtensionAbility {
onRequest(want, startId) {
console.log('onRequest, want:' + want.abilityName + 'startId:' + startId);
}
}
```
## InputMethodExtensionAbility.onConnect()
onConnect(want: Want): rpc.RemoteObject
Extension生命周期回调,在输入法extention首次连接输入法ability时回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**返回值**
| 类型 | 说明 |
| ------------------------------- | ------------------------------------------------------------ |
| rpc.RemoteObject | 一个RemoteObject对象,用于和客户端进行通信。 |
**示例:**
```ts
import rpc from '@ohos.rpc'
class StubTest extends rpc.RemoteObject{
constructor(des) {
super(des);
}
onConnect(code, data, reply, option) {
}
}
class ServiceExt extends ServiceExtension {
onConnect(want) {
console.log('onConnect , want:' + want.abilityName);
return new StubTest("test");
}
}
```
## InputMethodExtensionAbility.onDisconnect()
onDisconnect(want: Want): void
Extension生命周期回调,在所有连接在输入法extention上的ability都断开的时候回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**示例:**
```ts
class InputMethodExt extends InputMethodExtensionAbility {
onDisconnect(want) {
console.log('onDisconnect, want:' + want.abilityName);
}
}
```
## InputMethodExtensionAbility.onReconnect()
onReconnect(want: Want): void
Extension生命周期回调,在一个新的客户端去尝试连接输入法extention的时候回调(先前连接在extention上的客户端全部断开的情况下)。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 |
**示例:**
```ts
class InputMethodExt extends InputMethodExtensionAbility {
onReconnect(want) {
console.log('onReconnect, want:' + want.abilityName);
}
}
```
......@@ -22,7 +22,7 @@ import inputMethod from '@ohos.inputmethod';
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| MAX_TYPE_NUM | number | 是 | 否 | 可支持的最大输入法个数。 |
| EXCEPTION_PERMISSION<sup>9+</sup> | number | 是 | 否 | 错误码。详见../errorcodes/errcode-inputmethod-framework.md,下同 |
| EXCEPTION_PERMISSION<sup>9+</sup> | number | 是 | 否 | 错误码。详见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md),下同 |
| EXCEPTION_PARAMCHECK<sup>9+</sup> | number | 是 | 否 | 错误码。 |
| EXCEPTION_UNSUPPORTED<sup>9+</sup> | number | 是 | 否 | 错误码。 |
| EXCEPTION_PACKAGEMANAGER<sup>9+</sup> | number | 是 | 否 | 错误码。 |
......@@ -45,12 +45,12 @@ import inputMethod from '@ohos.inputmethod';
| -------- | -------- | -------- | -------- | -------- |
| packageName<sup>(deprecated)</sup> | string | 是 | 否 | 包名。 |
| methodId<sup>(deprecated)</sup> | string | 是 | 否 | Ability名。 |
| name<sup>9+</sup> | string | 是 | 否 | 包名,非必填项。 |
| id<sup>9+</sup> | string | 是 | 否 | Ability名,非必填项。 |
| label<sup>9+</sup> | string | 是 | 否 | 输入法标签,非必填项。|
| name<sup>9+</sup> | string | 是 | 否 | 包名。 |
| id<sup>9+</sup> | string | 是 | 否 | Ability名。 |
| label<sup>9+</sup> | string | 是 | 否 | 输入法标签,非必填项。|
| icon<sup>9+</sup> | string | 是 | 否 | 输入法图标,非必填项。 |
| iconId<sup>9+</sup> | number | 是 | 否 | 输入法图标id,非必填项。 |
| extra<sup>9+</sup> | object | 是 | 否 | 输入法其他信息,非必填项。 |
| extra<sup>9+</sup> | object | 是 | 否 | 输入法其他信息。 |
## inputMethod.getController<sup>9+</sup>
......@@ -58,8 +58,6 @@ getController(): InputMethodController
获取客户端实例[InputMethodController](#inputmethodcontroller)
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
**返回值:**
......@@ -68,9 +66,17 @@ getController(): InputMethodController
| ----------------------------------------------- | ------------------------ |
| [InputMethodController](#inputmethodcontroller) | 回调返回当前客户端实例。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800006 | Input method controller error. |
**示例:**
```ts
```js
let InputMethodController = inputMethod.getController();
```
......@@ -80,8 +86,6 @@ getSetting(): InputMethodSetting
获取客户端设置实例[InputMethodSetting](#inputmethodsetting8)
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
......@@ -90,9 +94,17 @@ getSetting(): InputMethodSetting
| ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#inputmethodsetting8) | 回调返回当前客户端设置实例。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800007 | Input method settings extension error. |
**示例:**
```ts
```js
let InputMethodSetting = inputMethod.getSetting();
```
......@@ -102,8 +114,6 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea
切换输入法。使用callback异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**需要权限**: ohos.permission.CONNECT_IME_ABILITY
**系统能力**:SystemCapability.MiscServices.InputMethodFramework
......@@ -115,9 +125,18 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea
| target | [InputMethodProperty](#inputmethodproperty8) | 是 | 传入要切换的目标输入法。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当输入法切换成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
try{
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'}, (err, result) => {
if (err) {
......@@ -139,8 +158,6 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
切换输入法。使用promise异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**需要权限**: ohos.permission.CONNECT_IME_ABILITY
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
......@@ -157,9 +174,18 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
| ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise对象。返回true表示切换输入法成功;返回false表示切换输入法失败。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
try {
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'}).then((result) => {
if (result) {
......@@ -181,8 +207,6 @@ getCurrentInputMethod(): InputMethodProperty
获取当前输入法扩展应用,提供同步接口,返回当前输入法属性。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
......@@ -193,7 +217,7 @@ getCurrentInputMethod(): InputMethodProperty
**示例:**
```ts
```js
let currentIme = inputMethod.getCurrentInputMethod();
```
......@@ -203,8 +227,6 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
在当前输入法应用内切换子类型。使用callback异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**需要权限**: ohos.permission.CONNECT_IME_ABILITY
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
......@@ -216,9 +238,18 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
| target | [InputMethodSubtype](./js-apis-inputmethodsubtype.md#inputmethodsubtype)| 是 | 传入要切换的目标输入法子类型。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当输入法子类型切换成功,err为undefined,data为true;否则为错误对象。|
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
let inputMethodSubtype = {
id: "com.example.kikainput",
label: "ServiceExtAbility"
......@@ -246,8 +277,6 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
在当前输入法应用内切换子类型。使用promise异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**需要权限**: ohos.permission.CONNECT_IME_ABILITY
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
......@@ -264,9 +293,18 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
| ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise对象。返回true表示在当前输入法应用内切换子类型成功;返回false表示在当前输入法应用内切换子类型失败。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
let inputMethodSubtype = {
id: "com.example.kikainput",
label: "ServiceExtAbility"
......@@ -292,8 +330,6 @@ getCurrentInputMethodSubtype(): InputMethodSubtype
获取当前输入法子类型。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
......@@ -304,7 +340,7 @@ getCurrentInputMethodSubtype(): InputMethodSubtype
**示例:**
```ts
```js
let currentImeSubType = inputMethod.getCurrentInputMethodSubtype();
```
......@@ -314,8 +350,6 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用callback异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**需要权限**: ohos.permission.CONNECT_IME_ABILITY
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
......@@ -328,9 +362,18 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
|inputMethodSubtype | [InputMethodSubtype](./js-apis-inputmethodsubtype.md#inputmethodsubtype)| 是 | 传入要切换的目标输入法子类型。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当输入法和子类型切换成功,err为undefined,data为获取到的切换子类型结果true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
let inputMethodProperty = {
packageName:"com.example.kikakeyboard",
methodId:"ServiceExtAbility"
......@@ -362,8 +405,6 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用promise异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**需要权限**: ohos.permission.CONNECT_IME_ABILITY
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
......@@ -381,9 +422,18 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
| ----------------------------------------- | ---------------------------- |
| Promise\<boolean> | Promise对象。返回true表示切换至指定输入法应用的指定子类型成功;返回false表示切换至指定输入法应用的指定子类型失败。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
let inputMethodProperty = {
name: "com.example.kikakeyboard",
id: "ServiceExtAbility"
......@@ -475,6 +525,15 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当输入法隐藏成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```js
......@@ -509,6 +568,15 @@ stopInputSession(): Promise&lt;boolean&gt;
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise对象。返回true表示输入法隐藏成功;返回false表示输入法隐藏失败。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```js
......@@ -543,6 +611,15 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当软键盘显示成功。err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```js
......@@ -571,6 +648,15 @@ showSoftKeyboard(): Promise&lt;void&gt;
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```js
......@@ -597,6 +683,15 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当软键盘隐藏成功。err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```js
......@@ -625,6 +720,15 @@ hideSoftKeyboard(): Promise&lt;void&gt;
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. |
**示例:**
```js
......@@ -756,8 +860,6 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
获取指定输入法应用的所有子类型。使用callback异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:**
......@@ -767,9 +869,18 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
| inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用
| callback | Array<[InputMethodSubtype](./js-apis-inputmethodsubtype.md#inputmethodsubtype)> | 是 | 回调函数,返回指定输入法应用的所有子类型。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
let inputMethodProperty = {
packageName:'com.example.kikakeyboard',
methodId:'com.example.kikakeyboard'
......@@ -793,8 +904,6 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr
获取指定输入法应用的所有子类型。使用promise异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:**
......@@ -809,9 +918,18 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodSubtype](./js-apis-inputmethodsubtype.md#inputmethodsubtype)>> | Promise对象,返回已安装输入法子类型列表。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
let inputMethodSubProperty = {
id: "com.example.kikainput",
label: "ServiceExtAbility"
......@@ -833,8 +951,6 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
查询当前输入法应用的所有子类型。使用callback异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:**
......@@ -843,9 +959,18 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array<[InputMethodSubtype](./js-apis-inputmethodsubtype.md#inputmethodsubtype)> | 是 | 回调函数,返回当前输入法应用的所有子类型。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
try {
InputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err) {
......@@ -865,8 +990,6 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
查询当前输入法的子类型列表。使用promise异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
......@@ -875,9 +998,18 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodSubtype](./js-apis-inputmethodsubtype.md#inputmethodsubtype)>> | Promise对象,返回当前输入法的子类型列表。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
try {
InputMethodSetting.listCurrentInputMethodSubtype().then((data) => {
console.info('listCurrentInputMethodSubtype success');
......@@ -895,8 +1027,6 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
获取已激活/未激活输入法列表。参数enable取true,返回已激活输入法列表,取false返回未激活输入法列表。使用callback异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:**
......@@ -906,9 +1036,18 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
| enable | boolean | 是 | 指定返回已激活/未激活。 |
| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | 是 | 回调函数,返回已激活/未激活输入法列表。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
try {
InputMethodSetting.getInputMethods(true, (err,data) => {
if (err) {
......@@ -928,8 +1067,6 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt
获取已激活/未激活输入法列表。参数enable取true返回已激活输入法列表,取false返回未激活输入法列表。使用promise异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:**
......@@ -938,6 +1075,15 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt
| ------ | ------- | ---- | ----------------------- |
| enable | boolean | 是 | 指定返回已激活/未激活。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. |
**返回值:**
| 类型 | 说明 |
......@@ -946,7 +1092,7 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt
**示例:**
```ts
```js
try {
InputMethodSetting.getInputMethods(true).then((data) => {
console.info('getInputMethods success');
......@@ -964,8 +1110,6 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
显示输入法选择对话框。使用callback异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**需要权限**: ohos.permission.CONNECT_IME_ABILITY
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
......@@ -976,9 +1120,17 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当输入法选择对话框显示成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
try {
InputMethodSetting.showOptionalInputMethods((err) => {
if (err) {
......@@ -998,8 +1150,6 @@ showOptionalInputMethods(): Promise&lt;boolean&gt;
显示输入法选择对话框。使用promise异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**需要权限**: ohos.permission.CONNECT_IME_ABILITY
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
......@@ -1010,9 +1160,17 @@ showOptionalInputMethods(): Promise&lt;boolean&gt;
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise对象。返回true表示输入法选择对话框显示成功;返回false表示输入法选择对话框显示失败。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
| 12800008 | Input method settings extension error. |
**示例:**
```ts
```js
InputMethodSetting.showOptionalInputMethods().then(() => {
console.info('displayOptionalInputMethod success.');
}).catch((err) => {
......
......@@ -801,6 +801,14 @@ hide(callback: AsyncCallback&lt;void&gt;): void
| -------- | ---------------------- | ---- | -------- |
| callback | AsyncCallback&lt;void> | 否 | 回调函数。当输入法隐藏成功,err为undefined,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -827,6 +835,14 @@ hide(): Promise&lt;void&gt;
| ---------------- | ------------------------- |
| Promise&lt;void> | Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -916,7 +932,15 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
| action | number | 是 | 编辑框属性。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```js
try {
......@@ -956,6 +980,14 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise对象。返回true表示功能键发送成功;返回false表示功能键发送失败。|
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -989,6 +1021,15 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数。当光标前固定长度的文本获取成功,err为undefined,data为获取到的文本;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```js
......@@ -1026,6 +1067,15 @@ getForward(length:number): Promise&lt;string&gt;
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;string&gt; | Promise对象,返回光标前固定长度的文本。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```js
......@@ -1058,6 +1108,15 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数。当光标后固定长度的文本获取成功,err为undefined,data为获取到的文本;否则为错误对象。|
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```js
......@@ -1095,6 +1154,15 @@ getBackward(length:number): Promise&lt;string&gt;
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;string&gt; | Promise对象,返回光标后固定长度的文本。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
| 12800003 | Input method client error. |
| 12800006 | Input method controller error. |
**示例:**
```js
......@@ -1127,6 +1195,15 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当光标前固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -1168,6 +1245,15 @@ deleteForward(length:number): Promise&lt;boolean&gt;
| ---------------------- | -------------- |
| Promise&lt;boolean&gt; | Promise对象。返回true表示删除光标前固定长度的文本成功;返回false表示删除光标前固定长度的文本失败。|
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -1204,7 +1290,16 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```js
let length = 1;
......@@ -1245,6 +1340,15 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise对象。返回true表示删除光标后固定长度的文本成功;返回false表示删除光标后固定长度的文本失败。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -1277,6 +1381,15 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
| text | string | 是 | 文本。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当文本插入成功,err为undefined,data为true;否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -1313,6 +1426,15 @@ insertText(text:string): Promise&lt;boolean&gt;
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise对象。返回true表示插入文本成功;返回false表示插入文本失败。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800002 | Input method engine error. |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -1347,6 +1469,14 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
| ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;[EditorAttribute](#EditorAttribute)&gt; | 是 | 回调函数。当编辑框属性值获取成功,err为undefined,data为编辑框属性值;否则为错误对象。|
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -1374,6 +1504,14 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;[EditorAttribute](#editorattribute)&gt; | Promise对象,返回编辑框属性值。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```js
......@@ -1393,8 +1531,6 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
移动光标。使用callback异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:**
......@@ -1404,9 +1540,17 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
| direction | number | 是 | 光标移动方向。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当光标移动成功,err为undefined,否则为错误对象 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```ts
```js
try {
InputClient.moveCursor(inputMethodAbility.CURSOR_xxx, (err) => {
if (err) {
......@@ -1426,8 +1570,6 @@ moveCursor(direction: number): Promise&lt;void&gt;
移动光标。使用promise异步回调。
**模型约束**: 此接口仅可在Stage模型下使用。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:**
......@@ -1442,9 +1584,17 @@ moveCursor(direction: number): Promise&lt;void&gt;
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
| 12800003 | Input method client error. |
**示例:**
```ts
```js
async function InputMethodAbility() {
try {
await InputClient.moveCursor(inputMethodEngine.CURSOR_xxx).then((err) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册