提交 f6c137f2 编写于 作者: H Hollokin

fixed 17f57a91 from https://gitee.com/hollokin/docs/pulls/12415

【输入法框架】API资料优化
Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 ca1a9d53
...@@ -31,14 +31,14 @@ import inputMethod from '@ohos.inputmethod'; ...@@ -31,14 +31,14 @@ import inputMethod from '@ohos.inputmethod';
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| name<sup>9+</sup> | string | 是 | 否 | 输入法内部名称。 | | name<sup>9+</sup> | string | 是 | 否 | 输入法内部名称。必填。|
| id<sup>9+</sup> | string | 是 | 否 | 输入法唯一标识。 | | id<sup>9+</sup> | string | 是 | 否 | 输入法唯一标识。必填。|
| label<sup>9+</sup> | string | 是 | 否 | 输入法对外显示名称。 | | label<sup>9+</sup> | string | 是 | 否 | 输入法对外显示名称。 非必填。|
| icon<sup>9+</sup> | string | 是 | 否 | 输入法图标数据。 | | icon<sup>9+</sup> | string | 是 | 否 | 输入法图标数据。非必填。 |
| iconId<sup>9+</sup> | number | 是 | 否 | 输入法图标资源号。 | | iconId<sup>9+</sup> | number | 是 | 否 | 输入法图标资源号。非必填。 |
| extra<sup>9+</sup> | object | 是 | 否 | 输入法扩展信息。 | | extra<sup>9+</sup> | object | 是 | 是 | 输入法扩展信息。 必填。|
| packageName<sup>(deprecated)</sup> | string | 是 | 否 | 输入法包名。<br/>**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用name替代。 | | packageName<sup>(deprecated)</sup> | string | 是 | 否 | 输入法包名。必填。<br/>**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用name替代。 |
| methodId<sup>(deprecated)</sup> | string | 是 | 否 | 输入法唯一标识。<br/>**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用id替代。 | | methodId<sup>(deprecated)</sup> | string | 是 | 否 | 输入法唯一标识。必填。<br/>**说明:** 从API version 8开始支持,从API version 9开始废弃,建议使用id替代。 |
## inputMethod.getController<sup>9+</sup> ## inputMethod.getController<sup>9+</sup>
...@@ -102,7 +102,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea ...@@ -102,7 +102,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea
切换输入法。使用callback异步回调。 切换输入法。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -120,25 +120,33 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea ...@@ -120,25 +120,33 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. | | 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
let im = inputMethod.getCurrentInputMethod();
let prop = {
packageName: im.packageName,
methodId: im.methodId,
name: im.packageName,
id: im.methodId,
extra: {}
}
try{ try{
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard', extra: {}}, (err, result) => { inputMethod.switchInputMethod(prop, (err, result) => {
if (err) { if (err !== undefined) {
console.error('switchInputMethod err: ' + JSON.stringify(err)); console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to switchInputMethod.(callback)'); console.info('Succeeded in switching inputmethod.');
} else { } else {
console.error('Failed to switchInputMethod.(callback)'); console.error('Failed to switchInputMethod.');
} }
}); });
} catch(err) { } catch(err) {
console.error('switchInputMethod err: ' + JSON.stringify(err)); console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
} }
``` ```
## inputMethod.switchInputMethod<sup>9+</sup> ## inputMethod.switchInputMethod<sup>9+</sup>
...@@ -146,7 +154,7 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt; ...@@ -146,7 +154,7 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
切换输入法。使用promise异步回调。 切换输入法。使用promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -169,23 +177,31 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt; ...@@ -169,23 +177,31 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. | | 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
let im = inputMethod.getCurrentInputMethod();
let prop = {
packageName: im.packageName,
methodId: im.methodId,
name: im.packageName,
id: im.methodId,
extra: {}
}
try { try {
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard', extra: {}}).then((result) => { inputMethod.switchInputMethod(prop).then((result) => {
if (result) { if (result) {
console.info('Success to switchInputMethod.'); console.info('Succeeded in switching inputmethod.');
} else { } else {
console.error('Failed to switchInputMethod.'); console.error('Failed to switchInputMethod.');
} }
}).catch((err) => { }).catch((err) => {
console.error('switchInputMethod err: ' + JSON.stringify(err)); console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('switchInputMethod err: ' + JSON.stringify(err)); console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
} }
``` ```
...@@ -215,7 +231,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb ...@@ -215,7 +231,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
在当前输入法应用内切换子类型。使用callback异步回调。 在当前输入法应用内切换子类型。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -233,36 +249,35 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb ...@@ -233,36 +249,35 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. | | 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
let inputMethodSubtype = {
id: "com.example.kikakeyboard",
label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}
try { try {
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubtype, (err, result) => { inputMethod.switchCurrentInputMethodSubtype({
if (err) { id: "com.example.kikakeyboard",
console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err)); label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}, (err, result) => {
if (err !== undefined) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to switchCurrentInputMethodSubtype.(callback)'); console.info('Succeeded in switching currentInputMethodSubtype.');
} else { } else {
console.error('Failed to switchCurrentInputMethodSubtype.(callback)'); console.error('Failed to switchCurrentInputMethodSubtype');
} }
}); });
} catch(err) { } catch(err) {
console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -272,7 +287,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean& ...@@ -272,7 +287,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
在当前输入法应用内切换子类型。使用promise异步回调。 在当前输入法应用内切换子类型。使用promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -295,34 +310,33 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean& ...@@ -295,34 +310,33 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. | | 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
let inputMethodSubtype = {
id: "com.example.kikakeyboard",
label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}
try { try {
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubtype).then((result) => { inputMethod.switchCurrentInputMethodSubtype({
id: "com.example.kikakeyboard",
label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}).then((result) => {
if (result) { if (result) {
console.info('Success to switchCurrentInputMethodSubtype.'); console.info('Succeeded in switching currentInputMethodSubtype.');
} else { } else {
console.error('Failed to switchCurrentInputMethodSubtype.'); console.error('Failed to switchCurrentInputMethodSubtype.');
} }
}).catch((err) => { }).catch((err) => {
console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -352,7 +366,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -352,7 +366,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用callback异步回调。 切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -371,41 +385,43 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -371,41 +385,43 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. | | 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
let im = inputMethod.getCurrentInputMethod();
let inputMethodProperty = { let inputMethodProperty = {
packageName: "com.example.kikakeyboard", packageName: im.packageName,
methodId: "ServiceExtAbility", methodId: im.methodId,
extra: {} name: im.packageName,
} id: im.methodId,
let inputMethodSubProperty = {
id: "com.example.kikakeyboard",
label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {} extra: {}
} }
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,result) => { inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, {
if (err) { id: "com.example.kikakeyboard",
console.error('switchCurrentInputMethodAndSubtype err: ' + JSON.stringify(err)); label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}, (err,result) => {
if (err !== undefined) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to switchCurrentInputMethodAndSubtype.(callback)'); console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else { } else {
console.error('Failed to switchCurrentInputMethodAndSubtype.(callback)'); console.error('Failed to switchCurrentInputMethodAndSubtype.');
} }
}); });
} catch (err) { } catch (err) {
console.error('switchCurrentInputMethodAndSubtype err: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -415,7 +431,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -415,7 +431,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用promise异步回调。 切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -439,39 +455,41 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -439,39 +455,41 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. | | 12800005 | Configuration persisting error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
let im = inputMethod.getCurrentInputMethod();
let inputMethodProperty = { let inputMethodProperty = {
packageName: "com.example.kikakeyboard", packageName: im.packageName,
methodId: "ServiceExtAbility", methodId: im.methodId,
extra: {} name: im.packageName,
} id: im.methodId,
let inputMethodSubProperty = {
id: "com.example.kikakeyboard",
label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {} extra: {}
} }
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((result) => { inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, {
id: im.packageName,
label: im.methodId,
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}).then((result) => {
if (result) { if (result) {
console.info('Success to switchCurrentInputMethodAndSubtype.'); console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else { } else {
console.error('Failed to switchCurrentInputMethodAndSubtype.'); console.error('Failed to switchCurrentInputMethodAndSubtype.');
} }
}).catch((err) => { }).catch((err) => {
console.error('switchCurrentInputMethodAndSubtype err: ' + err); console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('switchCurrentInputMethodAndSubtype err: ' + err); console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -548,25 +566,25 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -548,25 +566,25 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
try { try {
inputMethodController.stopInputSession((error, result) => { inputMethodController.stopInputSession((error, result) => {
if (error) { if (error !== undefined) {
console.error('stopInputSession err: ' + JSON.stringify(error)); console.error('Failed to stopInputSession: ' + JSON.stringify(error));
return; return;
} }
if (result) { if (result) {
console.info('Success to stopInputSession.(callback)'); console.info('Succeeded in stopping inputSession.');
} else { } else {
console.error('Failed to stopInputSession.(callback)'); console.error('Failed to stopInputSession.');
} }
}); });
} catch(error) { } catch(error) {
console.error('stopInputSession err: ' + JSON.stringify(error)); console.error('Failed to stopInputSession: ' + JSON.stringify(error));
} }
``` ```
...@@ -591,7 +609,7 @@ stopInputSession(): Promise&lt;boolean&gt; ...@@ -591,7 +609,7 @@ stopInputSession(): Promise&lt;boolean&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
...@@ -599,15 +617,15 @@ stopInputSession(): Promise&lt;boolean&gt; ...@@ -599,15 +617,15 @@ stopInputSession(): Promise&lt;boolean&gt;
try { try {
inputMethodController.stopInputSession().then((result) => { inputMethodController.stopInputSession().then((result) => {
if (result) { if (result) {
console.info('Success to stopInputSession.'); console.info('Succeeded in stopping inputSession.');
} else { } else {
console.error('Failed to stopInputSession.'); console.error('Failed to stopInputSession.');
} }
}).catch((err) => { }).catch((err) => {
console.error('stopInputSession err: ' + JSON.stringify(err)); console.error('Failed to stopInputSession: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('stopInputSession err: ' + JSON.stringify(err)); console.error('Failed to stopInputSession: ' + JSON.stringify(err));
} }
``` ```
...@@ -617,7 +635,7 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -617,7 +635,7 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用callback异步回调。 显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -634,16 +652,16 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -634,16 +652,16 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodController.showSoftKeyboard((err) => { inputMethodController.showSoftKeyboard((err) => {
if (err === undefined) { if (err === undefined) {
console.info('showSoftKeyboard success'); console.info('Succeeded in showing softKeyboard.');
} else { } else {
console.error('showSoftKeyboard failed because : ' + JSON.stringify(err)); console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
} }
}) })
``` ```
...@@ -654,7 +672,7 @@ showSoftKeyboard(): Promise&lt;void&gt; ...@@ -654,7 +672,7 @@ showSoftKeyboard(): Promise&lt;void&gt;
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用Promise异步回调。 显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用Promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -671,15 +689,15 @@ showSoftKeyboard(): Promise&lt;void&gt; ...@@ -671,15 +689,15 @@ showSoftKeyboard(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodController.showSoftKeyboard().then(async (err) => { inputMethodController.showSoftKeyboard().then(() => {
console.log('showSoftKeyboard success'); console.log('Succeeded in showing softKeyboard.');
}).catch((err) => { }).catch((err) => {
console.error('showSoftKeyboard err: ' + JSON.stringify(err)); console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
}); });
``` ```
...@@ -689,7 +707,7 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -689,7 +707,7 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用callback异步回调。 隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -706,16 +724,16 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -706,16 +724,16 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodController.hideSoftKeyboard((err) => { inputMethodController.hideSoftKeyboard((err) => {
if (err === undefined) { if (err === undefined) {
console.info('hideSoftKeyboard success'); console.info('Succeeded in hiding softKeyboard.');
} else { } else {
console.error('hideSoftKeyboard failed because : ' + JSON.stringify(err)); console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
} }
}) })
``` ```
...@@ -726,7 +744,7 @@ hideSoftKeyboard(): Promise&lt;void&gt; ...@@ -726,7 +744,7 @@ hideSoftKeyboard(): Promise&lt;void&gt;
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用Promise异步回调。 隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用Promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -743,15 +761,15 @@ hideSoftKeyboard(): Promise&lt;void&gt; ...@@ -743,15 +761,15 @@ hideSoftKeyboard(): Promise&lt;void&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800003 | Input method client error. | | 12800003 | Input method client error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodController.hideSoftKeyboard().then(async (err) => { inputMethodController.hideSoftKeyboard().then(() => {
console.log('hideSoftKeyboard success'); console.log('Succeeded in hiding softKeyboard.');
}).catch((err) => { }).catch((err) => {
console.error('hideSoftKeyboard err: ' + JSON.stringify(err)); console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
}); });
``` ```
...@@ -777,14 +795,14 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -777,14 +795,14 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
inputMethodController.stopInput((error, result) => { inputMethodController.stopInput((error, result) => {
if (error) { if (error !== undefined) {
console.error('failed to stopInput because: ' + JSON.stringify(error)); console.error('Failed to stopInput: ' + JSON.stringify(error));
return; return;
} }
if (result) { if (result) {
console.info('Success to stopInput.(callback)'); console.info('Succeeded in stopping input.');
} else { } else {
console.error('Failed to stopInput.(callback)'); console.error('Failed to stopInput.');
} }
}); });
``` ```
...@@ -812,12 +830,12 @@ stopInput(): Promise&lt;boolean&gt; ...@@ -812,12 +830,12 @@ stopInput(): Promise&lt;boolean&gt;
```js ```js
inputMethodController.stopInput().then((result) => { inputMethodController.stopInput().then((result) => {
if (result) { if (result) {
console.info('Success to stopInput.'); console.info('Succeeded in stopping input.');
} else { } else {
console.error('Failed to stopInput.'); console.error('Failed to stopInput.');
} }
}).catch((err) => { }).catch((err) => {
console.error('stopInput err: ' + err); console.error('Failed to stopInput: ' + err);
}) })
``` ```
...@@ -891,26 +909,28 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async ...@@ -891,26 +909,28 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800001 | Package manager error. | | 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
let inputMethodProperty = { let inputMethodProperty = {
packageName:'com.example.kikakeyboard', packageName: 'com.example.kikakeyboard',
methodId:'com.example.kikakeyboard', methodId: 'com.example.kikakeyboard',
name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard',
extra:{} extra:{}
} }
try { try {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => {
if (err) { if (err !== undefined) {
console.error('listInputMethodSubtype failed: ' + JSON.stringify(err)); console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
console.log('listInputMethodSubtype success'); console.log('Succeeded in listing inputMethodSubtype.');
}); });
} catch (err) { } catch (err) {
console.error('listInputMethodSubtype failed: ' + JSON.stringify(err)); console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -941,24 +961,26 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr ...@@ -941,24 +961,26 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800001 | Package manager error. | | 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
let inputMethodProperty = { let inputMethodProperty = {
packageName:'com.example.kikakeyboard', packageName: 'com.example.kikakeyboard',
methodId:'com.example.kikakeyboard', methodId: 'com.example.kikakeyboard',
name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard',
extra:{} extra:{}
} }
try { try {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => {
console.info('listInputMethodSubtype success'); console.info('Succeeded in listing inputMethodSubtype.');
}).catch((err) => { }).catch((err) => {
console.error('listInputMethodSubtype err: ' + JSON.stringify(err)); console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('listInputMethodSubtype err: ' + JSON.stringify(err)); console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -983,21 +1005,21 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub ...@@ -983,21 +1005,21 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800001 | Package manager error. | | 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
try { try {
inputMethodSetting.listCurrentInputMethodSubtype((err, data) => { inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err) { if (err !== undefined) {
console.error('listCurrentInputMethodSubtype failed: ' + JSON.stringify(err)); console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
console.log('listCurrentInputMethodSubtype success'); console.log('Succeeded in listing currentInputMethodSubtype.');
}); });
} catch(err) { } catch(err) {
console.error('listCurrentInputMethodSubtype err: ' + JSON.stringify(err)); console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -1022,19 +1044,19 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt; ...@@ -1022,19 +1044,19 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800001 | Package manager error. | | 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
try { try {
inputMethodSetting.listCurrentInputMethodSubtype().then((data) => { inputMethodSetting.listCurrentInputMethodSubtype().then((data) => {
console.info('listCurrentInputMethodSubtype success'); console.info('Succeeded in listing currentInputMethodSubtype.');
}).catch((err) => { }).catch((err) => {
console.error('listCurrentInputMethodSubtype err: ' + err); console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('listCurrentInputMethodSubtype err: ' + JSON.stringify(err)); console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -1060,21 +1082,21 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod ...@@ -1060,21 +1082,21 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800001 | Package manager error. | | 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
try { try {
inputMethodSetting.getInputMethods(true, (err,data) => { inputMethodSetting.getInputMethods(true, (err,data) => {
if (err) { if (err !== undefined) {
console.error('getInputMethods failed: ' + JSON.stringify(err)); console.error('Failed to getInputMethods: ' + JSON.stringify(err));
return; return;
} }
console.log('getInputMethods success'); console.log('Succeeded in getting inputMethods.');
}); });
} catch (err) { } catch (err) {
console.error('getInputMethods failed: ' + JSON.stringify(err)); console.error('Failed to getInputMethods: ' + JSON.stringify(err));
} }
``` ```
...@@ -1099,7 +1121,7 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt ...@@ -1099,7 +1121,7 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800001 | Package manager error. | | 12800001 | Package manager error. |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**返回值:** **返回值:**
...@@ -1112,12 +1134,12 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt ...@@ -1112,12 +1134,12 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt
```js ```js
try { try {
inputMethodSetting.getInputMethods(true).then((data) => { inputMethodSetting.getInputMethods(true).then((data) => {
console.info('getInputMethods success'); console.info('Succeeded in getting inputMethods.');
}).catch((err) => { }).catch((err) => {
console.error('getInputMethods err: ' + JSON.stringify(err)); console.error('Failed to getInputMethods: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('getInputMethods err: ' + JSON.stringify(err)); console.error('Failed to getInputMethods: ' + JSON.stringify(err));
} }
``` ```
...@@ -1127,7 +1149,7 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1127,7 +1149,7 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
显示输入法选择对话框。使用callback异步回调。 显示输入法选择对话框。使用callback异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1143,21 +1165,21 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1143,21 +1165,21 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
try { try {
inputMethodSetting.showOptionalInputMethods((err, data) => { inputMethodSetting.showOptionalInputMethods((err, data) => {
if (err) { if (err !== undefined) {
console.error('showOptionalInputMethods failed: ' + JSON.stringify(err)); console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
return; return;
} }
console.info('showOptionalInputMethods success'); console.info('Succeeded in showing optionalInputMethods.');
}); });
} catch (err) { } catch (err) {
console.error('showOptionalInputMethods failed: ' + JSON.stringify(err)); console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
} }
``` ```
...@@ -1167,7 +1189,7 @@ showOptionalInputMethods(): Promise&lt;boolean&gt; ...@@ -1167,7 +1189,7 @@ showOptionalInputMethods(): Promise&lt;boolean&gt;
显示输入法选择对话框。使用promise异步回调。 显示输入法选择对话框。使用promise异步回调。
**需要权限:** ohos.permission.CONNECT_IME_ABILITY **需要权限:** ohos.permission.CONNECT_IME_ABILITY,仅系统应用可用。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1183,15 +1205,15 @@ showOptionalInputMethods(): Promise&lt;boolean&gt; ...@@ -1183,15 +1205,15 @@ showOptionalInputMethods(): Promise&lt;boolean&gt;
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------------------------------------- | | -------- | -------------------------------------- |
| 12800008 | Input method settings extension error. | | 12800008 | Input method manager service error. |
**示例:** **示例:**
```js ```js
inputMethodSetting.showOptionalInputMethods().then((data) => { inputMethodSetting.showOptionalInputMethods().then((data) => {
console.info('displayOptionalInputMethod success.'); console.info('Succeeded in showing optionalInputMethods.');
}).catch((err) => { }).catch((err) => {
console.error('displayOptionalInputMethod err: ' + err); console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
}) })
``` ```
...@@ -1217,11 +1239,11 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;) ...@@ -1217,11 +1239,11 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
```js ```js
inputMethodSetting.listInputMethod((err,data) => { inputMethodSetting.listInputMethod((err,data) => {
if (err) { if (err !== undefined) {
console.error('listInputMethod failed because: ' + JSON.stringify(err)); console.error('Failed to listInputMethod: ' + JSON.stringify(err));
return; return;
} }
console.log('listInputMethod success'); console.log('Succeeded in listing inputMethod.');
}); });
``` ```
...@@ -1247,9 +1269,9 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt; ...@@ -1247,9 +1269,9 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
```js ```js
inputMethodSetting.listInputMethod().then((data) => { inputMethodSetting.listInputMethod().then((data) => {
console.info('listInputMethod success'); console.info('Succeeded in listing inputMethod.');
}).catch((err) => { }).catch((err) => {
console.error('listInputMethod err: ' + JSON.stringify(err)); console.error('Failed to listInputMethod: ' + JSON.stringify(err));
}) })
``` ```
...@@ -1275,11 +1297,11 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void ...@@ -1275,11 +1297,11 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodSetting.displayOptionalInputMethod((err) => { inputMethodSetting.displayOptionalInputMethod((err) => {
if (err) { if (err !== undefined) {
console.error('displayOptionalInputMethod failed because: ' + JSON.stringify(err)); console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err));
return; return;
} }
console.info('displayOptionalInputMethod success'); console.info('Succeeded in displaying optionalInputMethod.');
}); });
``` ```
...@@ -1305,8 +1327,8 @@ displayOptionalInputMethod(): Promise&lt;void&gt; ...@@ -1305,8 +1327,8 @@ displayOptionalInputMethod(): Promise&lt;void&gt;
```js ```js
inputMethodSetting.displayOptionalInputMethod().then(() => { inputMethodSetting.displayOptionalInputMethod().then(() => {
console.info('displayOptionalInputMethod success'); console.info('Succeeded in displaying optionalInputMethod.');
}).catch((err) => { }).catch((err) => {
console.error('displayOptionalInputMethod err: ' + err); console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err));
}) })
``` ```
...@@ -137,7 +137,7 @@ createKeyboardDelegate(): KeyboardDelegate ...@@ -137,7 +137,7 @@ createKeyboardDelegate(): KeyboardDelegate
**示例:** **示例:**
```js ```js
let KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); let keyboardDelegate = inputMethodEngine.createKeyboardDelegate();
``` ```
## InputMethodEngine ## InputMethodEngine
...@@ -162,9 +162,9 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli ...@@ -162,9 +162,9 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
**示例:** **示例:**
```js ```js
inputMethodEngine.getInputMethodEngine().on('inputStart', (kbController, textInputClient) => { inputMethodEngine.getInputMethodEngine().on('inputStart', (kbController, textClient) => {
KeyboardController = kbController; let keyboardController = kbController;
TextInputClient = textInputClient; let textInputClient = textClient;
}); });
``` ```
...@@ -235,12 +235,8 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void ...@@ -235,12 +235,8 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
**示例:** **示例:**
```js ```js
inputMethodEngine.getInputMethodEngine().off('keyboardShow', () => { inputMethodEngine.getInputMethodEngine().off('keyboardShow');
console.log('inputMethodEngine delete keyboardShow notification.'); inputMethodEngine.getInputMethodEngine().off('keyboardHide');
});
inputMethodEngine.getInputMethodEngine().off('keyboardHide', () => {
console.log('inputMethodEngine delete keyboardHide notification.');
});
``` ```
## InputMethodAbility ## InputMethodAbility
...@@ -265,9 +261,9 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: ...@@ -265,9 +261,9 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient:
**示例:** **示例:**
```js ```js
inputMethodEngine.getInputMethodAbility().on('inputStart', (kbController, inputClient) => { inputMethodEngine.getInputMethodAbility().on('inputStart', (kbController, client) => {
KeyboardController = kbController; let keyboardController = kbController;
InputClient = inputClient; let inputClient = client;
}); });
``` ```
...@@ -289,9 +285,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien ...@@ -289,9 +285,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien
**示例:** **示例:**
```js ```js
inputMethodEngine.getInputMethodAbility().off('inputStart', (kbController, inputClient) => { inputMethodEngine.getInputMethodAbility().off('inputStart');
console.log('delete inputStart notification.');
});
``` ```
### on('inputStop')<sup>9+</sup> ### on('inputStop')<sup>9+</sup>
...@@ -492,7 +486,7 @@ inputMethodEngine.getInputMethodAbility().off('setSubtype', () => { ...@@ -492,7 +486,7 @@ inputMethodEngine.getInputMethodAbility().off('setSubtype', () => {
on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
订阅硬键盘事件。使用callback异步回调。 订阅硬键盘(即物理键盘)事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -522,7 +516,7 @@ inputMethodEngine.getKeyboardDelegate().on('keyDown', (keyEvent) => { ...@@ -522,7 +516,7 @@ inputMethodEngine.getKeyboardDelegate().on('keyDown', (keyEvent) => {
off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
取消订阅硬键盘事件。使用callback异步回调。 取消订阅硬键盘(即物理键盘)事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -602,14 +596,14 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi ...@@ -602,14 +596,14 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本选择变化事件。<br/>-&nbsp;type为’selectionChange‘时,表示选择文本变化。 | | type | string | 是 | 文本选择变化事件。<br/>-&nbsp;type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。<br/>-&nbsp;oldBegin为变化之前被选中文本的起始下标。<br/>-&nbsp;oldEnd为变化之前被选中文本的终止下标。<br/>-&nbsp;newBegin为变化之后被选中文本的起始下标。<br/>-&nbsp;newEnd为变化之后被选中文本的终止下标。 | | callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。<br/>-&nbsp;oldBegin为变化之前被选中文本的起始下标。<br/>-&nbsp;oldEnd为变化之前被选中文本的终止下标。<br/>-&nbsp;newBegin为变化之后被选中文本的起始下标。<br/>-&nbsp;newEnd为变化之后被选中文本的终止下标。 |
**示例:** **示例:**
```js ```js
inputMethodEngine.getKeyboardDelegate().on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { inputMethodEngine.getKeyboardDelegate().on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
...@@ -652,14 +646,14 @@ on(type: 'textChange', callback: (text: string) => void): void ...@@ -652,14 +646,14 @@ on(type: 'textChange', callback: (text: string) => void): void
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本变化事件。<br/>-&nbsp;type为’textChange‘时,表示订阅文本变化事件。 | | type | string | 是 | 文本变化事件。<br/>-&nbsp;type为’textChange‘时,表示订阅文本变化事件。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。 | | callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。 |
**示例:** **示例:**
```js ```js
inputMethodEngine.getKeyboardDelegate().on('textChange', (text) => { inputMethodEngine.getKeyboardDelegate().on('textChange', (text) => {
...@@ -719,12 +713,12 @@ hide(callback: AsyncCallback&lt;void&gt;): void ...@@ -719,12 +713,12 @@ hide(callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
KeyboardController.hide((err) => { keyboardController.hide((err) => {
if (err === undefined) { if (err !== undefined) {
console.error('hide err: ' + JSON.stringify(err)); console.error('Failed to hide keyboard: ' + JSON.stringify(err));
return; return;
} }
console.log('hide success.'); console.log('Succeeded in hiding keyboard.');
}); });
``` ```
...@@ -753,10 +747,10 @@ hide(): Promise&lt;void&gt; ...@@ -753,10 +747,10 @@ hide(): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
KeyboardController.hide().then(() => { keyboardController.hide().then(() => {
console.info('hide success.'); console.info('Succeeded in hiding keyboard.');
}).catch((err) => { }).catch((err) => {
console.info('hide err: ' + JSON.stringify(err)); console.info('Failed to hide keyboard: ' + JSON.stringify(err));
}); });
``` ```
...@@ -781,12 +775,12 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -781,12 +775,12 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
KeyboardController.hideKeyboard((err) => { keyboardController.hideKeyboard((err) => {
if (err === undefined) { if (err !== undefined) {
console.error('hideKeyboard err: ' + JSON.stringify(err)); console.error('Failed to hide Keyboard: ' + JSON.stringify(err));
return; return;
} }
console.log('hideKeyboard success.'); console.log('Succeeded in hiding keyboard.');
}); });
``` ```
...@@ -811,10 +805,10 @@ hideKeyboard(): Promise&lt;void&gt; ...@@ -811,10 +805,10 @@ hideKeyboard(): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
KeyboardController.hideKeyboard().then(() => { keyboardController.hideKeyboard().then(() => {
console.info('hideKeyboard success.'); console.info('Succeeded in hiding keyboard.');
}).catch((err) => { }).catch((err) => {
console.info('hideKeyboard err: ' + JSON.stringify(err)); console.info('Failed to hide Keyboard: ' + JSON.stringify(err));
}); });
``` ```
...@@ -850,13 +844,13 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -850,13 +844,13 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
let action = 1; let action = 1;
try { try {
InputClient.sendKeyFunction(action, (err, result) => { inputClient.sendKeyFunction(action, (err, result) => {
if (err) { if (err !== undefined) {
console.error('sendKeyFunction err: ' + JSON.stringify(err)); console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to sendKeyFunction. '); console.info('Succeeded in sending key function. ');
} else { } else {
console.error('Failed to sendKeyFunction. '); console.error('Failed to sendKeyFunction. ');
} }
...@@ -899,17 +893,17 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt; ...@@ -899,17 +893,17 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt;
```js ```js
let action = 1; let action = 1;
try { try {
InputClient.sendKeyFunction(action).then((result) => { inputClient.sendKeyFunction(action).then((result) => {
if (result) { if (result) {
console.info('Success to sendKeyFunction. '); console.info('Succeeded in sending key function. ');
} else { } else {
console.error('Failed to sendKeyFunction. '); console.error('Failed to sendKeyFunction. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('sendKeyFunction err:' + JSON.stringify(err)); console.error('Failed to sendKeyFunction:' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.error('sendKeyFunction err: ' + JSON.stringify(err)); console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
} }
``` ```
...@@ -942,15 +936,15 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -942,15 +936,15 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js ```js
let length = 1; let length = 1;
try { try {
InputClient.getForward(length, (err, text) => { inputClient.getForward(length, (err, text) => {
if (err) { if (err !== undefined) {
console.error('getForward err: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
console.log('getForward result: ' + text); console.log('Succeeded in getting forward, text: ' + text);
}); });
} catch (err) { } catch (err) {
console.error('getForward err: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
} }
``` ```
...@@ -988,13 +982,13 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -988,13 +982,13 @@ getForward(length:number): Promise&lt;string&gt;
```js ```js
let length = 1; let length = 1;
try { try {
InputClient.getForward(length).then((text) => { inputClient.getForward(length).then((text) => {
console.info('getForward resul: ' + text); console.info('Succeeded in getting forward, text: ' + text);
}).catch((err) => { }).catch((err) => {
console.error('getForward err: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.error('getForward err: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1027,15 +1021,15 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1027,15 +1021,15 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js ```js
let length = 1; let length = 1;
try { try {
InputClient.getBackward(length, (err, text) => { inputClient.getBackward(length, (err, text) => {
if (err) { if (err !== undefined) {
console.error('getBackward result: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
console.log('getBackward result---text: ' + text); console.log('Succeeded in getting backward, text: ' + text);
}); });
} catch (err) { } catch (err) {
console.error('getBackward result: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1073,13 +1067,13 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -1073,13 +1067,13 @@ getBackward(length:number): Promise&lt;string&gt;
```js ```js
let length = 1; let length = 1;
try { try {
InputClient.getBackward(length).then((text) => { inputClient.getBackward(length).then((text) => {
console.info('getBackward result: ' + text); console.info('Succeeded in getting backward, text: ' + text);
}).catch((err) => { }).catch((err) => {
console.error('getBackward err: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.error('getBackward err: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1112,19 +1106,19 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1112,19 +1106,19 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
let length = 1; let length = 1;
try { try {
InputClient.deleteForward(length, (err, result) => { inputClient.deleteForward(length, (err, result) => {
if (err) { if (err !== undefined) {
console.error('deleteForward result: ' + JSON.stringify(err)); console.error('Failed to delete forward: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to deleteForward. '); console.info('Succeeded in deleting forward. ');
} else { } else {
console.error('Failed to deleteForward. '); console.error('Failed to delete forward: ' + JSON.stringify(err));
} }
}); });
} catch (err) { } catch (err) {
console.error('deleteForward result: ' + JSON.stringify(err)); console.error('Failed to delete forward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1162,17 +1156,17 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -1162,17 +1156,17 @@ deleteForward(length:number): Promise&lt;boolean&gt;
```js ```js
let length = 1; let length = 1;
try { try {
InputClient.deleteForward(length).then((result) => { inputClient.deleteForward(length).then((result) => {
if (result) { if (result) {
console.info('Success to deleteForward. '); console.info('Succeeded in deleting forward. ');
} else { } else {
console.error('Failed to deleteForward. '); console.error('Failed to delete Forward. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('deleteForward err: ' + JSON.stringify(err)); console.error('Failed to delete Forward: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.error('deleteForward err: ' + JSON.stringify(err)); console.error('Failed to delete Forward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1205,15 +1199,15 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1205,15 +1199,15 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
let length = 1; let length = 1;
try { try {
InputClient.deleteBackward(length, (err, result) => { inputClient.deleteBackward(length, (err, result) => {
if (err) { if (err !== undefined) {
console.error('deleteBackward err: ' + JSON.stringify(err)); console.error('Failed to delete Backward: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to deleteBackward. '); console.info('Succeeded in deleting backward. ');
} else { } else {
console.error('Failed to deleteBackward. '); console.error('Failed to delete Backward: ' + JSON.stringify(err));
} }
}); });
} catch (err) { } catch (err) {
...@@ -1254,14 +1248,14 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -1254,14 +1248,14 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
```js ```js
let length = 1; let length = 1;
InputClient.deleteBackward(length).then((result) => { inputClient.deleteBackward(length).then((result) => {
if (result) { if (result) {
console.info('Success to deleteBackward. '); console.info('Succeeded in deleting backward. ');
} else { } else {
console.error('Failed to deleteBackward. '); console.error('Failed to deleteBackward. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('deleteBackward err: ' + JSON.stringify(err)); console.error('Failed to deleteBackward: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1292,13 +1286,13 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1292,13 +1286,13 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```js ```js
InputClient.insertText('test', (err, result) => { inputClient.insertText('test', (err, result) => {
if (err) { if (err !== undefined) {
console.error('insertText err: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to insertText. '); console.info('Succeeded in inserting text. ');
} else { } else {
console.error('Failed to insertText. '); console.error('Failed to insertText. ');
} }
...@@ -1338,17 +1332,17 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -1338,17 +1332,17 @@ insertText(text:string): Promise&lt;boolean&gt;
```js ```js
try { try {
InputClient.insertText('test').then((result) => { inputClient.insertText('test').then((result) => {
if (result) { if (result) {
console.info('Success to insertText. '); console.info('Succeeded in inserting text. ');
} else { } else {
console.error('Failed to insertText. '); console.error('Failed to insertText. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('insertText err: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.error('insertText err: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
} }
``` ```
...@@ -1377,9 +1371,9 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -1377,9 +1371,9 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
**示例:** **示例:**
```js ```js
InputClient.getEditorAttribute((err, editorAttribute) => { inputClient.getEditorAttribute((err, editorAttribute) => {
if (err) { if (err !== undefined) {
console.error('getEditorAttribute err: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return; return;
} }
console.log('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern)); console.log('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
...@@ -1412,11 +1406,11 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -1412,11 +1406,11 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
**示例:** **示例:**
```js ```js
InputClient.getEditorAttribute().then((editorAttribute) => { inputClient.getEditorAttribute().then((editorAttribute) => {
console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern)); console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType)); console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
}).catch((err) => { }).catch((err) => {
console.error('getEditorAttribute err: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1447,15 +1441,15 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1447,15 +1441,15 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
InputClient.moveCursor(inputMethodEngine.CURSOR_xxx, (err) => { inputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err) => {
if (err) { if (err !== undefined) {
console.error('moveCursor err: ' + JSON.stringify(err)); console.error('Failed to moveCursor: ' + JSON.stringify(err));
return; return;
} }
console.info('moveCursor success'); console.info('Succeeded in moving cursor.');
}); });
} catch (err) { } catch (err) {
console.error('moveCursor err: ' + JSON.stringify(err)); console.error('Failed to moveCursor: ' + JSON.stringify(err));
} }
``` ```
...@@ -1491,13 +1485,13 @@ moveCursor(direction: number): Promise&lt;void&gt; ...@@ -1491,13 +1485,13 @@ moveCursor(direction: number): Promise&lt;void&gt;
```js ```js
try { try {
InputClient.moveCursor(inputMethodEngine.CURSOR_UP).then(() => { inputClient.moveCursor(inputMethodEngine.CURSOR_UP).then(() => {
console.log('moveCursor success'); console.log('Succeeded in moving cursor.');
}).catch((err) => { }).catch((err) => {
console.error('moveCursor success err: ' + JSON.stringify(err)); console.error('Failed to moveCursor: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log('moveCursor err: ' + JSON.stringify(err)); console.log('Failed to moveCursor: ' + JSON.stringify(err));
} }
``` ```
...@@ -1554,12 +1548,12 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1554,12 +1548,12 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js ```js
let length = 1; let length = 1;
TextInputClient.getForward(length, (err, text) => { textInputClient.getForward(length, (err, text) => {
if (err === undefined) { if (err !== undefined) {
console.error('getForward err: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
console.log('getForward result---text: ' + text); console.log('Succeeded in getting forward, text: ' + text);
}); });
``` ```
...@@ -1591,10 +1585,10 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -1591,10 +1585,10 @@ getForward(length:number): Promise&lt;string&gt;
```js ```js
let length = 1; let length = 1;
TextInputClient.getForward(length).then((text) => { textInputClient.getForward(length).then((text) => {
console.info('getForward result: ' + JSON.stringify(text)); console.info('Succeeded in getting forward, text: ' + text);
}).catch((err) => { }).catch((err) => {
console.error('getForward err: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1621,12 +1615,12 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1621,12 +1615,12 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js ```js
let length = 1; let length = 1;
TextInputClient.getBackward(length, (err, text) => { textInputClient.getBackward(length, (err, text) => {
if (err === undefined) { if (err !== undefined) {
console.error('getBackward err: ' + JSON.stringify(err)); console.error('Failed to getBackward: ' + JSON.stringify(err));
return; return;
} }
console.log('getBackward result---text: ' + text); console.log('Succeeded in getting borward, text: ' + text);
}); });
``` ```
...@@ -1658,10 +1652,10 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -1658,10 +1652,10 @@ getBackward(length:number): Promise&lt;string&gt;
```js ```js
let length = 1; let length = 1;
TextInputClient.getBackward(length).then((text) => { textInputClient.getBackward(length).then((text) => {
console.info('getBackward result: ' + JSON.stringify(text)); console.info('Succeeded in getting backward: ' + JSON.stringify(text));
}).catch((err) => { }).catch((err) => {
console.error('getBackward err: ' + JSON.stringify(err)); console.error('Failed to getBackward: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1688,13 +1682,13 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1688,13 +1682,13 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
let length = 1; let length = 1;
TextInputClient.deleteForward(length, (err, result) => { textInputClient.deleteForward(length, (err, result) => {
if (err === undefined) { if (err !== undefined) {
console.error('deleteForward err: ' + JSON.stringify(err)); console.error('Failed to deleteForward: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to deleteForward. '); console.info('Succeeded in deleting forward. ');
} else { } else {
console.error('Failed to deleteForward. '); console.error('Failed to deleteForward. ');
} }
...@@ -1729,14 +1723,14 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -1729,14 +1723,14 @@ deleteForward(length:number): Promise&lt;boolean&gt;
```js ```js
let length = 1; let length = 1;
TextInputClient.deleteForward(length).then((result) => { textInputClient.deleteForward(length).then((result) => {
if (result) { if (result) {
console.info('Succeed in deleting forward. '); console.info('Succeeded in deleting forward. ');
} else { } else {
console.error('Failed to delete forward. '); console.error('Failed to delete forward. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to delete forward err: ' + JSON.stringify(err)); console.error('Failed to delete forward: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1763,13 +1757,13 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1763,13 +1757,13 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
let length = 1; let length = 1;
TextInputClient.deleteBackward(length, (err, result) => { textInputClient.deleteBackward(length, (err, result) => {
if (err === undefined) { if (err !== undefined) {
console.error('deleteBackward err: ' + JSON.stringify(err)); console.error('Failed to delete backward: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to deleteBackward. '); console.info('Succeeded in deleting backward. ');
} else { } else {
console.error('Failed to deleteBackward. '); console.error('Failed to deleteBackward. ');
} }
...@@ -1804,14 +1798,14 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -1804,14 +1798,14 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
```js ```js
let length = 1; let length = 1;
TextInputClient.deleteBackward(length).then((result) => { textInputClient.deleteBackward(length).then((result) => {
if (result) { if (result) {
console.info('Success to deleteBackward. '); console.info('Succeeded in deleting backward. ');
} else { } else {
console.error('Failed to deleteBackward. '); console.error('Failed to deleteBackward. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('deleteBackward err: ' + JSON.stringify(err)); console.error('Failed to deleteBackward: ' + JSON.stringify(err));
}); });
``` ```
### sendKeyFunction<sup>(deprecated)</sup> ### sendKeyFunction<sup>(deprecated)</sup>
...@@ -1837,13 +1831,13 @@ sendKeyFunction(action: number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1837,13 +1831,13 @@ sendKeyFunction(action: number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
let action = 1; let action = 1;
TextInputClient.sendKeyFunction(action, (err, result) => { textInputClient.sendKeyFunction(action, (err, result) => {
if (err === undefined) { if (err !== undefined) {
console.error('sendKeyFunction err: ' + JSON.stringify(err)); console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to sendKeyFunction. '); console.info('Succeeded in sending key function. ');
} else { } else {
console.error('Failed to sendKeyFunction. '); console.error('Failed to sendKeyFunction. ');
} }
...@@ -1878,14 +1872,14 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt; ...@@ -1878,14 +1872,14 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt;
```js ```js
let action = 1; let action = 1;
TextInputClient.sendKeyFunction(action).then((result) => { textInputClient.sendKeyFunction(action).then((result) => {
if (result) { if (result) {
console.info('Success to sendKeyFunction. '); console.info('Succeeded in sending key function. ');
} else { } else {
console.error('Failed to sendKeyFunction. '); console.error('Failed to sendKeyFunction. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('sendKeyFunction err:' + JSON.stringify(err)); console.error('Failed to sendKeyFunction:' + JSON.stringify(err));
}); });
``` ```
...@@ -1911,13 +1905,13 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1911,13 +1905,13 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```js ```js
TextInputClient.insertText('test', (err, result) => { textInputClient.insertText('test', (err, result) => {
if (err === undefined) { if (err !== undefined) {
console.error('insertText err: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Success to insertText. '); console.info('Succeeded in inserting text. ');
} else { } else {
console.error('Failed to insertText. '); console.error('Failed to insertText. ');
} }
...@@ -1951,14 +1945,14 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -1951,14 +1945,14 @@ insertText(text:string): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
TextInputClient.insertText('test').then((result) => { textInputClient.insertText('test').then((result) => {
if (result) { if (result) {
console.info('Success to insertText. '); console.info('Succeeded in inserting text. ');
} else { } else {
console.error('Failed to insertText. '); console.error('Failed to insertText. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('insertText err: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1983,9 +1977,9 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -1983,9 +1977,9 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
**示例:** **示例:**
```js ```js
TextInputClient.getEditorAttribute((err, editorAttribute) => { textInputClient.getEditorAttribute((err, editorAttribute) => {
if (err === undefined) { if (err !== undefined) {
console.error('getEditorAttribute err: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return; return;
} }
console.log('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern)); console.log('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
...@@ -2014,10 +2008,10 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -2014,10 +2008,10 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
**示例:** **示例:**
```js ```js
TextInputClient.getEditorAttribute().then((editorAttribute) => { textInputClient.getEditorAttribute().then((editorAttribute) => {
console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern)); console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType)); console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
}).catch((err) => { }).catch((err) => {
console.error('getEditorAttribute err: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
}); });
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册