提交 47a3a514 编写于 作者: H Hollokin

输入法错误码相关API资料补充

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 5f45cefd
...@@ -32,8 +32,8 @@ import inputMethod from '@ohos.inputmethod'; ...@@ -32,8 +32,8 @@ import inputMethod from '@ohos.inputmethod';
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| packageName<sup>deprecated</sup> | string | 是 | 否 | 包名。 | | packageName<sup>(deprecated)</sup> | string | 是 | 否 | 包名。 |
| methodId<sup>deprecated</sup> | string | 是 | 否 | Ability名。 | | methodId<sup>(deprecated)</sup> | string | 是 | 否 | Ability名。 |
| name<sup>9+</sup> | string | 是 | 否 | 包名,非必填项。 | | name<sup>9+</sup> | string | 是 | 否 | 包名,非必填项。 |
| id<sup>9+</sup> | string | 是 | 否 | Ability名,非必填项。 | | id<sup>9+</sup> | string | 是 | 否 | Ability名,非必填项。 |
| label<sup>9+</sup> | string | 是 | 否 | 输入法标签,非必填项。| | label<sup>9+</sup> | string | 是 | 否 | 输入法标签,非必填项。|
...@@ -41,7 +41,7 @@ import inputMethod from '@ohos.inputmethod'; ...@@ -41,7 +41,7 @@ import inputMethod from '@ohos.inputmethod';
| iconId<sup>9+</sup> | number | 是 | 否 | 输入法图标id,非必填项。 | | iconId<sup>9+</sup> | number | 是 | 否 | 输入法图标id,非必填项。 |
| extra<sup>9+</sup> | object | 是 | 否 | 输入法其他信息,非必填项。 | | extra<sup>9+</sup> | object | 是 | 否 | 输入法其他信息,非必填项。 |
## inputMethod.getInputMethodController<sup>deprecated</sup> ## inputMethod.getInputMethodController<sup>(deprecated)</sup>
getInputMethodController(): InputMethodController getInputMethodController(): InputMethodController
...@@ -86,7 +86,7 @@ getController(): InputMethodController ...@@ -86,7 +86,7 @@ getController(): InputMethodController
var InputMethodController = inputMethod.getController(); var InputMethodController = inputMethod.getController();
``` ```
## inputMethod.getInputMethodSetting<sup>deprecated</sup> ## inputMethod.getInputMethodSetting<sup>(deprecated)</sup>
getInputMethodSetting(): InputMethodSetting getInputMethodSetting(): InputMethodSetting
...@@ -169,7 +169,7 @@ try{ ...@@ -169,7 +169,7 @@ try{
}); });
} catch(err) { } catch(err) {
// 捕获参数错误 // 捕获参数错误
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('switchInputMethod err: ' + JSON.stringify(err));
} }
``` ```
## inputMethod.switchInputMethod<sup>9+</sup> ## inputMethod.switchInputMethod<sup>9+</sup>
...@@ -204,10 +204,10 @@ try { ...@@ -204,10 +204,10 @@ try {
console.error('Failed to switchInputMethod.(promise)'); console.error('Failed to switchInputMethod.(promise)');
} }
}).catch((err) => { }).catch((err) => {
console.error('switchInputMethod promise err: ' + err); console.error('switchInputMethod promise err: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('switchInputMethod err: ' + JSON.stringify(err));
} }
``` ```
...@@ -268,7 +268,7 @@ try { ...@@ -268,7 +268,7 @@ try {
} }
}); });
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err));
} }
``` ```
...@@ -303,10 +303,10 @@ try { ...@@ -303,10 +303,10 @@ try {
console.error('Failed to switchCurrentInputMethodSubtype.(promise)'); console.error('Failed to switchCurrentInputMethodSubtype.(promise)');
} }
}).catch((err) => { }).catch((err) => {
console.error('switchCurrentInputMethodSubtype promise err: ' + err); console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('switchCurrentInputMethodSubtype err: ' + JSON.stringify(err));
} }
``` ```
...@@ -353,14 +353,14 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -353,14 +353,14 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
**示例:** **示例:**
```js ```js
let inputMethodProperty = {
packageName:"com.example.kikakeyboard",
methodId:"ServiceExtAbility"
}
let inputMethodSubProperty = { let inputMethodSubProperty = {
id: "com.example.kikainput", id: "com.example.kikainput",
label: "ServiceExtAbility" label: "ServiceExtAbility"
} }
let inputMethodProperty = {
name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard'
}
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,result) => { inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,result) => {
if (err) { if (err) {
...@@ -374,7 +374,7 @@ try { ...@@ -374,7 +374,7 @@ try {
} }
}); });
} catch (err) { } catch (err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('switchCurrentInputMethodAndSubtype err: ' + JSON.stringify(err));
} }
``` ```
...@@ -398,14 +398,14 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -398,14 +398,14 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
**示例:** **示例:**
```js ```js
let inputMethodProperty = {
packageName:"com.example.kikakeyboard",
methodId:"ServiceExtAbility"
}
let inputMethodSubProperty = { let inputMethodSubProperty = {
id: "com.example.kikainput", id: "com.example.kikainput",
label: "ServiceExtAbility" label: "ServiceExtAbility"
} }
let inputMethodProperty = {
name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard'
}
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(property, subType).then((result) => { inputMethod.switchCurrentInputMethodAndSubtype(property, subType).then((result) => {
if (result) { if (result) {
...@@ -417,7 +417,7 @@ try { ...@@ -417,7 +417,7 @@ try {
console.error('switchCurrentInputMethodAndSubtype promise err: ' + err); console.error('switchCurrentInputMethodAndSubtype promise err: ' + err);
}) })
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('switchCurrentInputMethodAndSubtype promise err: ' + err);
} }
``` ```
...@@ -425,12 +425,17 @@ try { ...@@ -425,12 +425,17 @@ try {
下列API示例中都需使用[getController](#inputmethodgetcontroller)回调获取到InputMethodController实例,再通过此实例调用对应方法。 下列API示例中都需使用[getController](#inputmethodgetcontroller)回调获取到InputMethodController实例,再通过此实例调用对应方法。
### stopInput<sup>deprecated</sup> ### stopInput<sup>(deprecated)</sup>
stopInput(callback: AsyncCallback&lt;boolean&gt;): void stopInput(callback: AsyncCallback&lt;boolean&gt;): void
隐藏输入法。使用callback形式返回结果。参数个数为1,否则抛出异常。 隐藏输入法。使用callback形式返回结果。参数个数为1,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[stopInputSession](#stopInputSession)替代
>
> 从 API version 6开始支持。
**系统能力**:SystemCapability.MiscServices.InputMethodFramework **系统能力**:SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
...@@ -455,12 +460,17 @@ InputMethodController.stopInput((error, result) => { ...@@ -455,12 +460,17 @@ InputMethodController.stopInput((error, result) => {
}); });
``` ```
### stopInput<sup>deprecated</sup> ### stopInput<sup>(deprecated)</sup>
stopInput(): Promise&lt;boolean&gt; stopInput(): Promise&lt;boolean&gt;
隐藏输入法。使用promise形式返回结果。参数个数为0,否则抛出异常。 隐藏输入法。使用promise形式返回结果。参数个数为0,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[stopInputSession](#stopInputSession)替代
>
> 从 API version 6开始支持。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework **系统能力**: SystemCapability.MiscServices.InputMethodFramework
**返回值:** **返回值:**
...@@ -503,7 +513,7 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -503,7 +513,7 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
try { try {
InputMethodController.stopInputSession((error, result) => { InputMethodController.stopInputSession((error, result) => {
if (error) { if (error) {
console.error('failed to stopInputSession because: ' + JSON.stringify(error)); console.error('stopInputSession err: ' + JSON.stringify(error));
return; return;
} }
if (result) { if (result) {
...@@ -512,8 +522,8 @@ try { ...@@ -512,8 +522,8 @@ try {
console.error('Failed to stopInputSession.(callback)'); console.error('Failed to stopInputSession.(callback)');
} }
}); });
} catch(err) { } catch(error) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('stopInputSession err: ' + JSON.stringify(error));
} }
``` ```
...@@ -542,10 +552,10 @@ try { ...@@ -542,10 +552,10 @@ try {
console.error('Failed to stopInputSession.(promise)'); console.error('Failed to stopInputSession.(promise)');
} }
}).catch((err) => { }).catch((err) => {
console.error('stopInputSession promise err: ' + err); console.error('stopInputSession err: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('stopInputSession err: ' + JSON.stringify(err));
} }
``` ```
...@@ -724,13 +734,13 @@ let inputMethodSubProperty = { ...@@ -724,13 +734,13 @@ let inputMethodSubProperty = {
try { try {
InputMethodSetting.listInputMethodSubtype(inputMethodSubProperty, (err,data) => { InputMethodSetting.listInputMethodSubtype(inputMethodSubProperty, (err,data) => {
if (err) { if (err) {
console.error('listInputMethodSubtype failed because: ' + JSON.stringify(err)); console.error('listInputMethodSubtype failed: ' + JSON.stringify(err));
return; return;
} }
console.log('listInputMethodSubtype success'); console.log('listInputMethodSubtype success');
}); });
} catch (err) { } catch (err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('listInputMethodSubtype failed: ' + JSON.stringify(err));
} }
``` ```
...@@ -759,10 +769,10 @@ try { ...@@ -759,10 +769,10 @@ try {
InputMethodSetting.listInputMethodSubtype(inputMethodSubProperty).then((data) => { InputMethodSetting.listInputMethodSubtype(inputMethodSubProperty).then((data) => {
console.info('listInputMethodSubtype success'); console.info('listInputMethodSubtype success');
}).catch((err) => { }).catch((err) => {
console.error('listInputMethodSubtype promise err: ' + err); console.error('listInputMethodSubtype err: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('listInputMethodSubtype err: ' + JSON.stringify(err));
} }
``` ```
...@@ -784,15 +794,15 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub ...@@ -784,15 +794,15 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
```js ```js
try { try {
InputMethodSetting.listCurrentInputMethodSubtype((err,data) => { InputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err) { if (err) {
console.error('listCurrentInputMethodSubtype failed because: ' + JSON.stringify(err)); console.error('listCurrentInputMethodSubtype failed: ' + JSON.stringify(err));
return; return;
} }
console.log('listCurrentInputMethodSubtype success'); console.log('listCurrentInputMethodSubtype success');
}); });
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('listCurrentInputMethodSubtype err: ' + JSON.stringify(err));
} }
``` ```
...@@ -820,9 +830,8 @@ try { ...@@ -820,9 +830,8 @@ try {
console.error('listCurrentInputMethodSubtype promise err: ' + err); console.error('listCurrentInputMethodSubtype promise err: ' + err);
}) })
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('listCurrentInputMethodSubtype err: ' + JSON.stringify(err));
} }
``` ```
### getInputMethods<sup>9+</sup> ### getInputMethods<sup>9+</sup>
...@@ -846,13 +855,13 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod ...@@ -846,13 +855,13 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
try { try {
InputMethodSetting.getInputMethods(true, (err,data) => { InputMethodSetting.getInputMethods(true, (err,data) => {
if (err) { if (err) {
console.error('getInputMethods failed because: ' + JSON.stringify(err)); console.error('getInputMethods failed: ' + JSON.stringify(err));
return; return;
} }
console.log('getInputMethods success'); console.log('getInputMethods success');
}); });
} catch (err) { } catch (err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('getInputMethods failed: ' + JSON.stringify(err));
} }
``` ```
...@@ -883,19 +892,24 @@ try { ...@@ -883,19 +892,24 @@ try {
InputMethodSetting.getInputMethods(true).then((data) => { InputMethodSetting.getInputMethods(true).then((data) => {
console.info('getInputMethods success'); console.info('getInputMethods success');
}).catch((err) => { }).catch((err) => {
console.error('getInputMethods promise err: ' + err); console.error('getInputMethods promise err: ' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('getInputMethods promise err: ' + JSON.stringify(err));
} }
``` ```
### listInputMethod<sup>deprecated</sup> ### listInputMethod<sup>(deprecated)</sup>
listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;): void
查询已安装的输入法列表。使用callback形式返回结果。参数个数为1,否则抛出异常。 查询已安装的输入法列表。使用callback形式返回结果。参数个数为1,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[getInputMethods](#getInputMethods)替代
>
> 从 API version 8开始支持。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework **系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
...@@ -916,12 +930,17 @@ InputMethodSetting.listInputMethod((err,data) => { ...@@ -916,12 +930,17 @@ InputMethodSetting.listInputMethod((err,data) => {
}); });
``` ```
### listInputMethod<sup>deprecated</sup> ### listInputMethod<sup>(deprecated)</sup>
listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt; listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
查询已安装的输入法列表。使用promise形式返回结果。参数个数为0,否则抛出异常。 查询已安装的输入法列表。使用promise形式返回结果。参数个数为0,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[getInputMethods](#getInputMethods)替代
>
> 从 API version 8开始支持。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework **系统能力**: SystemCapability.MiscServices.InputMethodFramework
**返回值:** **返回值:**
...@@ -936,16 +955,21 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt; ...@@ -936,16 +955,21 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
InputMethodSetting.listInputMethod().then((data) => { InputMethodSetting.listInputMethod().then((data) => {
console.info('listInputMethod success'); console.info('listInputMethod success');
}).catch((err) => { }).catch((err) => {
console.error('listInputMethod promise err: ' + err); console.error('listInputMethod promise err: ' + JSON.stringify(err));
}) })
``` ```
### displayOptionalInputMethod<sup>deprecated</sup> ### displayOptionalInputMethod<sup>(deprecated)</sup>
displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
显示输入法选择对话框。使用callback形式返回结果。参数个数为1,否则抛出异常。 显示输入法选择对话框。使用callback形式返回结果。参数个数为1,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[showOptionalInputMethods](#showOptionalInputMethods)替代
>
> 从 API version 8开始支持。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework **系统能力**: SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
...@@ -988,22 +1012,27 @@ showOptionalInputMethods(callback: AsyncCallback&lt;void&gt;): void ...@@ -988,22 +1012,27 @@ showOptionalInputMethods(callback: AsyncCallback&lt;void&gt;): void
try { try {
InputMethodSetting.showOptionalInputMethods((err) => { InputMethodSetting.showOptionalInputMethods((err) => {
if (err) { if (err) {
console.error('showOptionalInputMethods failed because: ' + JSON.stringify(err)); console.error('showOptionalInputMethods failed: ' + JSON.stringify(err));
return; return;
} }
console.info('showOptionalInputMethods success'); console.info('showOptionalInputMethods success');
}); });
} catch (err) { } catch (err) {
console.error('err: ' + err.code + 'err message: ' + err.message); console.error('showOptionalInputMethods failed: ' + JSON.stringify(err));
} }
``` ```
### displayOptionalInputMethod<sup>deprecated</sup> ### displayOptionalInputMethod<sup>(deprecated)</sup>
displayOptionalInputMethod(): Promise&lt;void&gt; displayOptionalInputMethod(): Promise&lt;void&gt;
显示输入法选择对话框。使用promise形式返回结果。参数个数为0,否则抛出异常。 显示输入法选择对话框。使用promise形式返回结果。参数个数为0,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[showOptionalInputMethods](#showOptionalInputMethods)替代
>
> 从 API version 8开始支持。
**系统能力**: SystemCapability.MiscServices.InputMethodFramework **系统能力**: SystemCapability.MiscServices.InputMethodFramework
**返回值:** **返回值:**
......
...@@ -51,7 +51,7 @@ import inputMethodEngine from '@ohos.inputmethodengine'; ...@@ -51,7 +51,7 @@ import inputMethodEngine from '@ohos.inputmethodengine';
| CURSOR_RIGHT<sup>9+</sup> | number | 是 | 否 | 光标右移。 | | CURSOR_RIGHT<sup>9+</sup> | number | 是 | 否 | 光标右移。 |
| WINDOW_TYPE_INPUT_METHOD_FLOAT<sup>9+</sup> | number | 是 | 否 | 输入法应用窗口风格标识。 | | WINDOW_TYPE_INPUT_METHOD_FLOAT<sup>9+</sup> | number | 是 | 否 | 输入法应用窗口风格标识。 |
## inputMethodEngine.getInputMethodEngine<a name="getInputMethodEngine"></a><sup>deprecated</sup> ## inputMethodEngine.getInputMethodEngine<a name="getInputMethodEngine"></a><sup>(deprecated)</sup>
getInputMethodEngine(): InputMethodEngine getInputMethodEngine(): InputMethodEngine
...@@ -76,7 +76,7 @@ getInputMethodEngine(): InputMethodEngine ...@@ -76,7 +76,7 @@ getInputMethodEngine(): InputMethodEngine
var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); var InputMethodEngine = inputMethodEngine.getInputMethodEngine();
``` ```
## inputMethodAbility.getInputMethodAbility<a name="getInputMethodAbility"></a><sup>9+</sup> ## inputMethodEngine.getInputMethodAbility<a name="getInputMethodAbility"></a><sup>9+</sup>
getInputMethodAbility(): InputMethodAbility getInputMethodAbility(): InputMethodAbility
...@@ -96,7 +96,7 @@ getInputMethodAbility(): InputMethodAbility ...@@ -96,7 +96,7 @@ getInputMethodAbility(): InputMethodAbility
var InputMethodAbility = inputMethodAbility.getInputMethodAbility(); var InputMethodAbility = inputMethodAbility.getInputMethodAbility();
``` ```
## inputMethodEngine.createKeyboardDelegate<a name="createKeyboardDelegate"></a><sup>deprecated</sup> ## inputMethodEngine.createKeyboardDelegate<a name="createKeyboardDelegate"></a><sup>(deprecated)</sup>
createKeyboardDelegate(): KeyboardDelegate createKeyboardDelegate(): KeyboardDelegate
...@@ -121,7 +121,7 @@ createKeyboardDelegate(): KeyboardDelegate ...@@ -121,7 +121,7 @@ createKeyboardDelegate(): KeyboardDelegate
var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
``` ```
## inputMethodAbility.getKeyboardDelegate<a name="getKeyboardDelegate"></a> ## inputMethodEngine.getKeyboardDelegate<a name="getKeyboardDelegate"></a>
getKeyboardDelegate(): KeyboardDelegate getKeyboardDelegate(): KeyboardDelegate
...@@ -163,7 +163,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli ...@@ -163,7 +163,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
**示例:** **示例:**
```js ```js
InputMethodEngine.on('inputStart', (kbController, textInputClient) => { inputMethodEngine.getInputMethodEngine().on('inputStart', (kbController, textInputClient) => {
KeyboardController = kbController; KeyboardController = kbController;
TextInputClient = textInputClient; TextInputClient = textInputClient;
}); });
...@@ -189,7 +189,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC ...@@ -189,7 +189,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
**示例:** **示例:**
```js ```js
InputMethodEngine.off('inputStart', (kbController, textInputClient) => { inputMethodEngine.getInputMethodEngine().off('inputStart', (kbController, textInputClient) => {
console.log('delete inputStart notification.'); console.log('delete inputStart notification.');
}); });
``` ```
...@@ -212,7 +212,7 @@ on(type: 'inputStop', callback: () => void): void ...@@ -212,7 +212,7 @@ on(type: 'inputStop', callback: () => void): void
**示例:** **示例:**
```js ```js
InputMethodEngine.getInputMethodEngine().on('inputStop', () => { inputMethodEngine.getInputMethodEngine().on('inputStop', () => {
console.log('inputMethodEngine inputStop'); console.log('inputMethodEngine inputStop');
}); });
``` ```
...@@ -235,7 +235,7 @@ off(type: 'inputStop', callback: () => void): void ...@@ -235,7 +235,7 @@ off(type: 'inputStop', callback: () => void): void
**示例:** **示例:**
```js ```js
InputMethodEngine.getInputMethodEngine().off('inputStop', () => { inputMethodEngine.getInputMethodEngine().off('inputStop', () => {
console.log('inputMethodEngine delete inputStop notification.'); console.log('inputMethodEngine delete inputStop notification.');
}); });
``` ```
...@@ -258,7 +258,7 @@ on(type: 'setCallingWindow', callback: (wid:number) => void): void ...@@ -258,7 +258,7 @@ on(type: 'setCallingWindow', callback: (wid:number) => void): void
**示例:** **示例:**
```js ```js
InputMethodEngine.getInputMethodEngine().on('setCallingWindow', (wid) => { inputMethodEngine.getInputMethodEngine().on('setCallingWindow', (wid) => {
console.log('inputMethodEngine setCallingWindow'); console.log('inputMethodEngine setCallingWindow');
}); });
``` ```
...@@ -281,7 +281,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void ...@@ -281,7 +281,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void
**示例:** **示例:**
```js ```js
InputMethodEngine.getInputMethodEngine().off('setCallingWindow', () => { inputMethodEngine.getInputMethodEngine().off('setCallingWindow', () => {
console.log('inputMethodEngine delete setCallingWindow notification.'); console.log('inputMethodEngine delete setCallingWindow notification.');
}); });
``` ```
...@@ -304,10 +304,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void ...@@ -304,10 +304,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
**示例:** **示例:**
```js ```js
InputMethodEngine.on('keyboardShow', () => { inputMethodEngine.getInputMethodEngine().on('keyboardShow', () => {
console.log('inputMethodEngine keyboardShow.'); console.log('inputMethodEngine keyboardShow.');
}); });
InputMethodEngine.on('keyboardHide', () => { inputMethodEngine.getInputMethodEngine().on('keyboardHide', () => {
console.log('inputMethodEngine keyboardHide.'); console.log('inputMethodEngine keyboardHide.');
}); });
``` ```
...@@ -330,17 +330,17 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void ...@@ -330,17 +330,17 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
**示例:** **示例:**
```js ```js
InputMethodEngine.off('keyboardShow', () => { inputMethodEngine.getInputMethodEngine().off('keyboardShow', () => {
console.log('inputMethodEngine delete keyboardShow notification.'); console.log('inputMethodEngine delete keyboardShow notification.');
}); });
InputMethodEngine.off('keyboardHide', () => { inputMethodEngine.getInputMethodEngine().off('keyboardHide', () => {
console.log('inputMethodEngine delete keyboardHide notification.'); console.log('inputMethodEngine delete keyboardHide notification.');
}); });
``` ```
## InputMethodAbility<a name="InputMethodAbility"></a> ## InputMethodAbility<a name="InputMethodAbility"></a>
下列API示例中都需使用[getInputMethodEngine](#getInputMethodEngine)回调获取到InputMethodEngine实例,再通过此实例调用对应方法。 下列API示例中都需使用[getInputMethodAbility](#getInputMethodAbility)回调获取到InputMethodAbility实例,再通过此实例调用对应方法。
### on('inputStart')<a name="inputStart"></a><sup>9+</sup> ### on('inputStart')<a name="inputStart"></a><sup>9+</sup>
...@@ -360,7 +360,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: ...@@ -360,7 +360,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient:
**示例:** **示例:**
```js ```js
InputMethodAbility.on('inputStart', (kbController, inputClient) => { inputMethodEngine.getInputMethodAbility().on('inputStart', (kbController, inputClient) => {
KeyboardController = kbController; KeyboardController = kbController;
InputClient = inputClient; InputClient = inputClient;
}); });
...@@ -384,7 +384,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien ...@@ -384,7 +384,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien
**示例:** **示例:**
```js ```js
InputMethodAbility.off('inputStart', (kbController, inputClient) => { inputMethodEngine.getInputMethodAbility().off('inputStart', (kbController, inputClient) => {
console.log('delete inputStart notification.'); console.log('delete inputStart notification.');
}); });
``` ```
...@@ -407,7 +407,7 @@ on(type: 'inputStop', callback: () => void): void ...@@ -407,7 +407,7 @@ on(type: 'inputStop', callback: () => void): void
**示例:** **示例:**
```js ```js
InputMethodAbility.getInputMethodAbility().on('inputStop', () => { inputMethodEngine.getInputMethodAbility().on('inputStop', () => {
console.log('inputMethodAbility inputStop'); console.log('inputMethodAbility inputStop');
}); });
``` ```
...@@ -430,7 +430,7 @@ off(type: 'inputStop', callback: () => void): void ...@@ -430,7 +430,7 @@ off(type: 'inputStop', callback: () => void): void
**示例:** **示例:**
```js ```js
InputMethodAbility.getInputMethodAbility().off('inputStop', () => { inputMethodEngine.getInputMethodAbility().off('inputStop', () => {
console.log('inputMethodAbility delete inputStop notification.'); console.log('inputMethodAbility delete inputStop notification.');
}); });
``` ```
...@@ -453,7 +453,7 @@ on(type: 'setCallingWindow', callback: (wid:number) => void): void ...@@ -453,7 +453,7 @@ on(type: 'setCallingWindow', callback: (wid:number) => void): void
**示例:** **示例:**
```js ```js
InputMethodAbility.getInputMethodAbility().on('setCallingWindow', (wid) => { inputMethodEngine.getInputMethodAbility().on('setCallingWindow', (wid) => {
console.log('inputMethodAbility setCallingWindow'); console.log('inputMethodAbility setCallingWindow');
}); });
``` ```
...@@ -476,7 +476,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void ...@@ -476,7 +476,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void
**示例:** **示例:**
```js ```js
InputMethodAbility.getInputMethodAbility().off('setCallingWindow', () => { inputMethodEngine.getInputMethodAbility().off('setCallingWindow', () => {
console.log('inputMethodAbility delete setCallingWindow notification.'); console.log('inputMethodAbility delete setCallingWindow notification.');
}); });
``` ```
...@@ -499,10 +499,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void ...@@ -499,10 +499,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
**示例:** **示例:**
```js ```js
InputMethodAbility.on('keyboardShow', () => { inputMethodEngine.getInputMethodAbility().on('keyboardShow', () => {
console.log('InputMethodAbility keyboardShow.'); console.log('InputMethodAbility keyboardShow.');
}); });
InputMethodAbility.on('keyboardHide', () => { inputMethodEngine.getInputMethodAbility().on('keyboardHide', () => {
console.log('InputMethodAbility keyboardHide.'); console.log('InputMethodAbility keyboardHide.');
}); });
``` ```
...@@ -525,10 +525,10 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void ...@@ -525,10 +525,10 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
**示例:** **示例:**
```js ```js
InputMethodAbility.off('keyboardShow', () => { inputMethodEngine.getInputMethodAbility().off('keyboardShow', () => {
console.log('InputMethodAbility delete keyboardShow notification.'); console.log('InputMethodAbility delete keyboardShow notification.');
}); });
InputMethodAbility.off('keyboardHide', () => { inputMethodEngine.getInputMethodAbility().off('keyboardHide', () => {
console.log('InputMethodAbility delete keyboardHide notification.'); console.log('InputMethodAbility delete keyboardHide notification.');
}); });
``` ```
...@@ -551,7 +551,7 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi ...@@ -551,7 +551,7 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi
**示例:** **示例:**
```js ```js
InputMethodAbility.on('setSubtype', (inputMethodSubtype) => { inputMethodEngine.getInputMethodAbility().on('setSubtype', (inputMethodSubtype) => {
console.log('InputMethodAbility setSubtype.'); console.log('InputMethodAbility setSubtype.');
}); });
``` ```
...@@ -574,14 +574,14 @@ off(type: 'setSubtype', callback?: () => void): void ...@@ -574,14 +574,14 @@ off(type: 'setSubtype', callback?: () => void): void
**示例:** **示例:**
```js ```js
InputMethodAbility.off('setSubtype', () => { inputMethodEngine.getInputMethodAbility().off('setSubtype', () => {
console.log('InputMethodAbility delete setSubtype notification.'); console.log('InputMethodAbility delete setSubtype notification.');
}); });
``` ```
## KeyboardDelegate<a name="KeyboardDelegate"></a> ## KeyboardDelegate<a name="KeyboardDelegate"></a>
下列API示例中都需使用[createKeyboardDelegate](#createKeyboardDelegate)回调获取到KeyboardDelegate实例,再通过此实例调用对应方法。 下列API示例中都需使用[getKeyboardDelegate](#getKeyboardDelegate)回调获取到KeyboardDelegate实例,再通过此实例调用对应方法。
### on('keyDown'|'keyUp') ### on('keyDown'|'keyUp')
...@@ -598,17 +598,15 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void ...@@ -598,17 +598,15 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
| type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyDown',表示订阅硬键盘按下。<br/>-&nbsp;type为'keyUp',表示订阅硬键盘抬起。 | | type | string | 是 | 设置监听类型。<br/>-&nbsp;type为'keyDown',表示订阅硬键盘按下。<br/>-&nbsp;type为'keyUp',表示订阅硬键盘抬起。 |
| callback | [KeyEvent](#KeyEvent) | 是 | 回调返回按键信息。 | | callback | [KeyEvent](#KeyEvent) | 是 | 回调返回按键信息。 |
**示例:** **示例:**
```js ```js
KeyboardDelegate.on('keyUp', (keyEvent) => { inputMethodEngine.getKeyboardDelegate().on('keyUp', (keyEvent) => {
console.info('inputMethodEngine keyCode.(keyUp):' + JSON.stringify(keyEvent.keyCode)); console.info('inputMethodEngine keyCode.(keyUp):' + JSON.stringify(keyEvent.keyCode));
console.info('inputMethodEngine keyAction.(keyUp):' + JSON.stringify(keyEvent.keyAction)); console.info('inputMethodEngine keyAction.(keyUp):' + JSON.stringify(keyEvent.keyAction));
return true; return true;
}); });
KeyboardDelegate.on('keyDown', (keyEvent) => { inputMethodEngine.getKeyboardDelegate().on('keyDown', (keyEvent) => {
console.info('inputMethodEngine keyCode.(keyDown):' + JSON.stringify(keyEvent.keyCode)); console.info('inputMethodEngine keyCode.(keyDown):' + JSON.stringify(keyEvent.keyCode));
console.info('inputMethodEngine keyAction.(keyDown):' + JSON.stringify(keyEvent.keyAction)); console.info('inputMethodEngine keyAction.(keyDown):' + JSON.stringify(keyEvent.keyAction));
return true; return true;
...@@ -633,11 +631,11 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void ...@@ -633,11 +631,11 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
**示例:** **示例:**
```js ```js
KeyboardDelegate.off('keyUp', (keyEvent) => { inputMethodEngine.getKeyboardDelegate().off('keyUp', (keyEvent) => {
console.log('delete keyUp notification.'); console.log('delete keyUp notification.');
return true; return true;
}); });
KeyboardDelegate.off('keyDown', (keyEvent) => { inputMethodEngine.getKeyboardDelegate().off('keyDown', (keyEvent) => {
console.log('delete keyDown notification.'); console.log('delete keyDown notification.');
return true; return true;
}); });
...@@ -663,7 +661,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = ...@@ -663,7 +661,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
**示例:** **示例:**
```js ```js
KeyboardDelegate.on('cursorContextChange', (x, y, height) => { inputMethodEngine.getKeyboardDelegate().on('cursorContextChange', (x, y, height) => {
console.log('inputMethodEngine cursorContextChange x:' + x); console.log('inputMethodEngine cursorContextChange x:' + x);
console.log('inputMethodEngine cursorContextChange y:' + y); console.log('inputMethodEngine cursorContextChange y:' + y);
console.log('inputMethodEngine cursorContextChange height:' + height); console.log('inputMethodEngine cursorContextChange height:' + height);
...@@ -689,7 +687,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) ...@@ -689,7 +687,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number)
**示例:** **示例:**
```js ```js
KeyboardDelegate.off('cursorContextChange', (x, y, height) => { inputMethodEngine.getKeyboardDelegate().off('cursorContextChange', (x, y, height) => {
console.log('delete cursorContextChange notification.'); console.log('delete cursorContextChange notification.');
}); });
``` ```
...@@ -711,7 +709,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi ...@@ -711,7 +709,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
**示例:** **示例:**
```js ```js
KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { inputMethodEngine.getKeyboardDelegate().on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.log('inputMethodEngine beforeEach selectionChange oldBegin:' + oldBegin); console.log('inputMethodEngine beforeEach selectionChange oldBegin:' + oldBegin);
console.log('inputMethodEngine beforeEach selectionChange oldEnd:' + oldEnd); console.log('inputMethodEngine beforeEach selectionChange oldEnd:' + oldEnd);
console.log('inputMethodEngine beforeEach selectionChange newBegin:' + newBegin); console.log('inputMethodEngine beforeEach selectionChange newBegin:' + newBegin);
...@@ -737,7 +735,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe ...@@ -737,7 +735,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
**示例:** **示例:**
```js ```js
KeyboardDelegate.off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { inputMethodEngine.getKeyboardDelegate().off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.log('delete selectionChange notification.'); console.log('delete selectionChange notification.');
}); });
``` ```
...@@ -761,7 +759,7 @@ on(type: 'textChange', callback: (text: string) => void): void ...@@ -761,7 +759,7 @@ on(type: 'textChange', callback: (text: string) => void): void
**示例:** **示例:**
```js ```js
KeyboardDelegate.on('textChange', (text) => { inputMethodEngine.getKeyboardDelegate().on('textChange', (text) => {
console.log('inputMethodEngine textChange. text:' + text); console.log('inputMethodEngine textChange. text:' + text);
}); });
``` ```
...@@ -784,7 +782,7 @@ off(type: 'textChange', callback?: (text: string) => void): void ...@@ -784,7 +782,7 @@ off(type: 'textChange', callback?: (text: string) => void): void
**示例:** **示例:**
```js ```js
keyboardDelegate.off('textChange', (text) => { inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
console.log('delete textChange notification. text:' + text); console.log('delete textChange notification. text:' + text);
}); });
``` ```
...@@ -809,11 +807,10 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -809,11 +807,10 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
KeyboardController.hideKeyboard((err) => { KeyboardController.hideKeyboard((err) => {
if (err === undefined) { if (err === undefined) {
console.error('hideKeyboard callback result---err: ' + err.msg); console.error('hideKeyboard callback result---err: ' + JSON.stringify(err));
return; return;
} }
console.log('hideKeyboard callback.'); console.log('hideKeyboard callback.');
...@@ -841,7 +838,7 @@ async function InputMethodEngine() { ...@@ -841,7 +838,7 @@ async function InputMethodEngine() {
await KeyboardController.hideKeyboard().then(() => { await KeyboardController.hideKeyboard().then(() => {
console.info('hideKeyboard promise.'); console.info('hideKeyboard promise.');
}).catch((err) => { }).catch((err) => {
console.info('hideKeyboard promise err: ' + err.msg); console.info('hideKeyboard promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
...@@ -850,7 +847,7 @@ async function InputMethodEngine() { ...@@ -850,7 +847,7 @@ async function InputMethodEngine() {
下列API示例中都需使用[inputStart](#inputStart)回调获取到TextInputClient实例,再通过此实例调用对应方法。 下列API示例中都需使用[inputStart](#inputStart)回调获取到TextInputClient实例,再通过此实例调用对应方法。
### getForward<sup>deprecated</sup> ### getForward<sup>(deprecated)</sup>
getForward(length:number, callback: AsyncCallback&lt;string&gt;): void getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
...@@ -876,14 +873,14 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -876,14 +873,14 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
var length = 1; var length = 1;
TextInputClient.getForward(length, (err, text) => { TextInputClient.getForward(length, (err, text) => {
if (err === undefined) { if (err === undefined) {
console.error('getForward callback result---err: ' + err.msg); console.error('getForward callback result---err: ' + JSON.stringify(err));
return; return;
} }
console.log('getForward callback result---text: ' + text); console.log('getForward callback result---text: ' + text);
}); });
``` ```
### getForward<sup>deprecated</sup> ### getForward<sup>(deprecated)</sup>
getForward(length:number): Promise&lt;string&gt; getForward(length:number): Promise&lt;string&gt;
...@@ -916,12 +913,12 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -916,12 +913,12 @@ getForward(length:number): Promise&lt;string&gt;
await TextInputClient.getForward(length).then((text) => { await TextInputClient.getForward(length).then((text) => {
console.info('getForward promise result---res: ' + text); console.info('getForward promise result---res: ' + text);
}).catch((err) => { }).catch((err) => {
console.error('getForward promise err: ' + err.msg); console.error('getForward promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
### getBackward<sup>deprecated</sup> ### getBackward<sup>(deprecated)</sup>
getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
...@@ -947,14 +944,14 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -947,14 +944,14 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
var length = 1; var length = 1;
TextInputClient.getBackward(length, (err, text) => { TextInputClient.getBackward(length, (err, text) => {
if (err === undefined) { if (err === undefined) {
console.error('getBackward callback result---err: ' + err.msg); console.error('getBackward callback result---err: ' + JSON.stringify(err));
return; return;
} }
console.log('getBackward callback result---text: ' + text); console.log('getBackward callback result---text: ' + text);
}); });
``` ```
### getBackward<sup>deprecated</sup> ### getBackward<sup>(deprecated)</sup>
getBackward(length:number): Promise&lt;string&gt; getBackward(length:number): Promise&lt;string&gt;
...@@ -987,12 +984,12 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -987,12 +984,12 @@ getBackward(length:number): Promise&lt;string&gt;
await TextInputClient.getBackward(length).then((text) => { await TextInputClient.getBackward(length).then((text) => {
console.info('getBackward promise result---res: ' + text); console.info('getBackward promise result---res: ' + text);
}).catch((err) => { }).catch((err) => {
console.error('getBackward promise err: ' + err.msg); console.error('getBackward promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
### deleteForward<sup>deprecated</sup> ### deleteForward<sup>(deprecated)</sup>
deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
...@@ -1018,7 +1015,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1018,7 +1015,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
var length = 1; var length = 1;
TextInputClient.deleteForward(length, (err, result) => { TextInputClient.deleteForward(length, (err, result) => {
if (err === undefined) { if (err === undefined) {
console.error('deleteForward callback result---err: ' + err.msg); console.error('deleteForward callback result---err: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
...@@ -1028,7 +1025,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1028,7 +1025,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
} }
}); });
``` ```
### deleteForward<sup>deprecated</sup> ### deleteForward<sup>(deprecated)</sup>
deleteForward(length:number): Promise&lt;boolean&gt; deleteForward(length:number): Promise&lt;boolean&gt;
...@@ -1065,12 +1062,12 @@ async function InputMethodEngine() { ...@@ -1065,12 +1062,12 @@ async function InputMethodEngine() {
console.error('Failed to deleteForward.(promise) '); console.error('Failed to deleteForward.(promise) ');
} }
}).catch((err) => { }).catch((err) => {
console.error('deleteForward promise err: ' + err.msg); console.error('deleteForward promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
### deleteBackward<sup>deprecated</sup> ### deleteBackward<sup>(deprecated)</sup>
deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
...@@ -1096,7 +1093,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1096,7 +1093,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
var length = 1; var length = 1;
TextInputClient.deleteBackward(length, (err, result) => { TextInputClient.deleteBackward(length, (err, result) => {
if (err === undefined) { if (err === undefined) {
console.error('deleteBackward callback result---err: ' + err.msg); console.error('deleteBackward callback result---err: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
...@@ -1107,7 +1104,7 @@ TextInputClient.deleteBackward(length, (err, result) => { ...@@ -1107,7 +1104,7 @@ TextInputClient.deleteBackward(length, (err, result) => {
}); });
``` ```
### deleteBackward<sup>deprecated</sup> ### deleteBackward<sup>(deprecated)</sup>
deleteBackward(length:number): Promise&lt;boolean&gt; deleteBackward(length:number): Promise&lt;boolean&gt;
...@@ -1144,11 +1141,11 @@ async function InputMethodEngine() { ...@@ -1144,11 +1141,11 @@ async function InputMethodEngine() {
console.error('Failed to deleteBackward.(promise) '); console.error('Failed to deleteBackward.(promise) ');
} }
}).catch((err) => { }).catch((err) => {
console.error('deleteBackward promise err: ' + err.msg); console.error('deleteBackward promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
### sendKeyFunction<sup>deprecated</sup> ### sendKeyFunction<sup>(deprecated)</sup>
sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
...@@ -1173,7 +1170,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1173,7 +1170,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
TextInputClient.sendKeyFunction(keyFunction, (err, result) => { TextInputClient.sendKeyFunction(keyFunction, (err, result) => {
if (err === undefined) { if (err === undefined) {
console.error('sendKeyFunction callback result---err: ' + err.msg); console.error('sendKeyFunction callback result---err: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
...@@ -1184,7 +1181,7 @@ TextInputClient.sendKeyFunction(keyFunction, (err, result) => { ...@@ -1184,7 +1181,7 @@ TextInputClient.sendKeyFunction(keyFunction, (err, result) => {
}); });
``` ```
### sendKeyFunction<sup>deprecated</sup> ### sendKeyFunction<sup>(deprecated)</sup>
sendKeyFunction(action:number): Promise&lt;boolean&gt; sendKeyFunction(action:number): Promise&lt;boolean&gt;
...@@ -1220,12 +1217,12 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt; ...@@ -1220,12 +1217,12 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
console.error('Failed to sendKeyFunction.(promise) '); console.error('Failed to sendKeyFunction.(promise) ');
} }
}).catch((err) => { }).catch((err) => {
console.error('sendKeyFunction promise err:' + err.msg); console.error('sendKeyFunction promise err:' + JSON.stringify(err));
}); });
} }
``` ```
### insertText<sup>deprecated</sup> ### insertText<sup>(deprecated)</sup>
insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
...@@ -1250,7 +1247,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1250,7 +1247,7 @@ 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 callback result---err: ' + err.msg); console.error('insertText callback result---err: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
...@@ -1261,7 +1258,7 @@ TextInputClient.insertText('test', (err, result) => { ...@@ -1261,7 +1258,7 @@ TextInputClient.insertText('test', (err, result) => {
}); });
``` ```
### insertText<sup>deprecated</sup> ### insertText<sup>(deprecated)</sup>
insertText(text:string): Promise&lt;boolean&gt; insertText(text:string): Promise&lt;boolean&gt;
...@@ -1297,12 +1294,12 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -1297,12 +1294,12 @@ insertText(text:string): Promise&lt;boolean&gt;
console.error('Failed to insertText.(promise) '); console.error('Failed to insertText.(promise) ');
} }
}).catch((err) => { }).catch((err) => {
console.error('insertText promise err: ' + err.msg); console.error('insertText promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
### getEditorAttribute<sup>deprecated</sup> ### getEditorAttribute<sup>(deprecated)</sup>
getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
...@@ -1326,7 +1323,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -1326,7 +1323,7 @@ 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 callback result---err: ' + err.msg); console.error('getEditorAttribute callback result---err: ' + JSON.stringify(err));
return; return;
} }
console.log('editorAttribute.inputPattern(callback): ' + JSON.stringify(editorAttribute.inputPattern)); console.log('editorAttribute.inputPattern(callback): ' + JSON.stringify(editorAttribute.inputPattern));
...@@ -1334,7 +1331,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -1334,7 +1331,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
}); });
``` ```
### getEditorAttribute<sup>deprecated</sup> ### getEditorAttribute<sup>(deprecated)</sup>
getEditorAttribute(): Promise&lt;EditorAttribute&gt; getEditorAttribute(): Promise&lt;EditorAttribute&gt;
...@@ -1361,7 +1358,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -1361,7 +1358,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
console.info('editorAttribute.inputPattern(promise): ' + JSON.stringify(editorAttribute.inputPattern)); console.info('editorAttribute.inputPattern(promise): ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.enterKeyType(promise): ' + JSON.stringify(editorAttribute.enterKeyType)); console.info('editorAttribute.enterKeyType(promise): ' + JSON.stringify(editorAttribute.enterKeyType));
}).catch((err) => { }).catch((err) => {
console.error('getEditorAttribute promise err: ' + err.msg); console.error('getEditorAttribute promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
...@@ -1388,17 +1385,21 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1388,17 +1385,21 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```js ```js
TextInputClient.sendKeyFunction(keyFunction, (err, result) => { try {
if (err === undefined) { InputClient.sendKeyFunction(keyFunction, (err, result) => {
console.error('sendKeyFunction callback result---err: ' + err.msg); if (err) {
return; console.error('sendKeyFunction err: ' + JSON.stringify(err)JSON.stringify(err));
} return;
if (result) { }
console.info('Success to sendKeyFunction.(callback) '); if (result) {
} else { console.info('Success to sendKeyFunction.(callback) ');
console.error('Failed to sendKeyFunction.(callback) '); } else {
} console.error('Failed to sendKeyFunction.(callback) ');
}); }
});
} catch (err) {
console.error('sendKeyFunction err: ' + JSON.stringify(err));
}
``` ```
### sendKeyFunction<sup>9+</sup> ### sendKeyFunction<sup>9+</sup>
...@@ -1424,17 +1425,19 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt; ...@@ -1424,17 +1425,19 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { try {
await client.sendKeyFunction(keyFunction).then((result) => { InputClient.sendKeyFunction(keyFunction).then((result) => {
if (result) { if (result) {
console.info('Success to sendKeyFunction.(promise) '); console.info('Success to sendKeyFunction.(callback) ');
} else { } else {
console.error('Failed to sendKeyFunction.(promise) '); console.error('Failed to sendKeyFunction.(callback) ');
} }
}).catch((err) => { }).catch((err) => {
console.error('sendKeyFunction promise err:' + err.msg); console.error('sendKeyFunction promise err:' + JSON.stringify(err));
}); });
} } catch (err) {
console.error('sendKeyFunction err: ' + JSON.stringify(err));
}
``` ```
### getForward<sup>9+</sup> ### getForward<sup>9+</sup>
...@@ -1456,13 +1459,17 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1456,13 +1459,17 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js ```js
var length = 1; var length = 1;
TextInputClient.getForward(length, (err, text) => { try {
if (err === undefined) { InputClient.getForward(length, (err, text) => {
console.error('getForward callback result---err: ' + err.msg); if (err) {
return; console.error('getForward err: ' + JSON.stringify(err));
} return;
console.log('getForward callback result---text: ' + text); }
}); console.log('getForward callback result: ' + text);
});
} catch (err) {
console.error('getForward err: ' + JSON.stringify(err));
}
``` ```
### getForward<sup>9+</sup> ### getForward<sup>9+</sup>
...@@ -1488,13 +1495,17 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -1488,13 +1495,17 @@ getForward(length:number): Promise&lt;string&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { async function InputMethodAbility() {
var length = 1; var length = 1;
await TextInputClient.getForward(length).then((text) => { try {
console.info('getForward promise result---res: ' + text); await InputClient.getForward(length).then((text) => {
}).catch((err) => { console.info('getForward promise resul: ' + text);
console.error('getForward promise err: ' + err.msg); }).catch((err) => {
}); console.error('getForward promise err: ' + JSON.stringify(err));
});
} catch (err) {
console.error('getForward promise err: ' + JSON.stringify(err));
}
} }
``` ```
...@@ -1517,13 +1528,17 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1517,13 +1528,17 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js ```js
var length = 1; var length = 1;
TextInputClient.getBackward(length, (err, text) => { try {
if (err === undefined) { InputClient.getBackward(length, (err, text) => {
console.error('getBackward callback result---err: ' + err.msg); if (err) {
return; console.error('getBackward callback result: ' + JSON.stringify(err));
} return;
console.log('getBackward callback result---text: ' + text); }
}); console.log('getBackward callback result---text: ' + text);
});
} catch (err) {
console.error('getBackward callback result: ' + JSON.stringify(err));
}
``` ```
### getBackward<sup>9+</sup> ### getBackward<sup>9+</sup>
...@@ -1549,13 +1564,17 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -1549,13 +1564,17 @@ getBackward(length:number): Promise&lt;string&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { async function InputMethodAbility() {
var length = 1; var length = 1;
await TextInputClient.getBackward(length).then((text) => { try {
console.info('getBackward promise result---res: ' + text); await InputClient.getBackward(length).then((text) => {
}).catch((err) => { console.info('getBackward promise result: ' + text);
console.error('getBackward promise err: ' + err.msg); }).catch((err) => {
}); console.error('getBackward promise err: ' + JSON.stringify(err));
});
} catch (err) {
console.error('getBackward promise err: ' + JSON.stringify(err));
}
} }
``` ```
...@@ -1577,19 +1596,24 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1577,19 +1596,24 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```js ```js
var length = 1; var length = 1;
TextInputClient.deleteForward(length, (err, result) => { try {
if (err === undefined) { InputClient.deleteForward(length, (err, result) => {
console.error('deleteForward callback result---err: ' + err.msg); if (err) {
return; console.error('deleteForward callback result: ' + JSON.stringify(err));
} return;
if (result) { }
console.info('Success to deleteForward.(callback) '); if (result) {
} else { console.info('Success to deleteForward.(callback) ');
console.error('Failed to deleteForward.(callback) '); } else {
} console.error('Failed to deleteForward.(callback) ');
}); }
});
} catch (err) {
console.error('deleteForward callback result: ' + JSON.stringify(err));
}
``` ```
### deleteForward<sup>9+</sup> ### deleteForward<sup>9+</sup>
deleteForward(length:number): Promise&lt;boolean&gt; deleteForward(length:number): Promise&lt;boolean&gt;
...@@ -1613,17 +1637,21 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -1613,17 +1637,21 @@ deleteForward(length:number): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { async function InputMethodAbility() {
var length = 1; var length = 1;
await TextInputClient.deleteForward(length).then((result) => { try {
if (result) { await InputClient.deleteForward(length).then((result) => {
console.info('Success to deleteForward.(promise) '); if (result) {
} else { console.info('Success to deleteForward.(promise) ');
console.error('Failed to deleteForward.(promise) '); } else {
} console.error('Failed to deleteForward.(promise) ');
}).catch((err) => { }
console.error('deleteForward promise err: ' + err.msg); }).catch((err) => {
}); console.error('deleteForward promise err: ' + JSON.stringify(err));
});
} catch (err) {
console.error('deleteForward promise err: ' + JSON.stringify(err));
}
} }
``` ```
...@@ -1646,9 +1674,9 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1646,9 +1674,9 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
var length = 1; var length = 1;
TextInputClient.deleteBackward(length, (err, result) => { InputClient.deleteBackward(length, (err, result) => {
if (err === undefined) { if (err) {
console.error('deleteBackward callback result---err: ' + err.msg); console.error('deleteBackward err: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
...@@ -1691,7 +1719,7 @@ async function InputMethodAbility() { ...@@ -1691,7 +1719,7 @@ async function InputMethodAbility() {
console.error('Failed to deleteBackward.(promise) '); console.error('Failed to deleteBackward.(promise) ');
} }
}).catch((err) => { }).catch((err) => {
console.error('deleteBackward promise err: ' + err.msg); console.error('deleteBackward promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
...@@ -1714,9 +1742,9 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1714,9 +1742,9 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
**示例:** **示例:**
```js ```js
TextInputClient.insertText('test', (err, result) => { InputClient.insertText('test', (err, result) => {
if (err === undefined) { if (err) {
console.error('insertText callback result---err: ' + err.msg); console.error('insertText err: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
...@@ -1750,16 +1778,20 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -1750,16 +1778,20 @@ insertText(text:string): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { async function InputMethodAbility() {
await TextInputClient.insertText('test').then((result) => { try {
if (result) { await InputClient.insertText('test').then((result) => {
console.info('Success to insertText.(promise) '); if (result) {
} else { console.info('Success to insertText.(promise) ');
console.error('Failed to insertText.(promise) '); } else {
} console.error('Failed to insertText.(promise) ');
}).catch((err) => { }
console.error('insertText promise err: ' + err.msg); }).catch((err) => {
}); console.error('insertText promise err: ' + JSON.stringify(err));
});
} catch (e) {
console.error('insertText promise err: ' + JSON.stringify(err));
}
} }
``` ```
...@@ -1780,9 +1812,9 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -1780,9 +1812,9 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
**示例:** **示例:**
```js ```js
TextInputClient.getEditorAttribute((err, editorAttribute) => { InputClient.getEditorAttribute((err, editorAttribute) => {
if (err === undefined) { if (err) {
console.error('getEditorAttribute callback result---err: ' + err.msg); console.error('getEditorAttribute callback result---err: ' + JSON.stringify(err));
return; return;
} }
console.log('editorAttribute.inputPattern(callback): ' + JSON.stringify(editorAttribute.inputPattern)); console.log('editorAttribute.inputPattern(callback): ' + JSON.stringify(editorAttribute.inputPattern));
...@@ -1808,11 +1840,11 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -1808,11 +1840,11 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
```js ```js
async function InputMethodEngine() { async function InputMethodEngine() {
await TextInputClient.getEditorAttribute().then((editorAttribute) => { await InputClient.getEditorAttribute().then((editorAttribute) => {
console.info('editorAttribute.inputPattern(promise): ' + JSON.stringify(editorAttribute.inputPattern)); console.info('editorAttribute.inputPattern(promise): ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.enterKeyType(promise): ' + JSON.stringify(editorAttribute.enterKeyType)); console.info('editorAttribute.enterKeyType(promise): ' + JSON.stringify(editorAttribute.enterKeyType));
}).catch((err) => { }).catch((err) => {
console.error('getEditorAttribute promise err: ' + err.msg); console.error('getEditorAttribute promise err: ' + JSON.stringify(err));
}); });
} }
``` ```
...@@ -1835,12 +1867,17 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1835,12 +1867,17 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```js
InputClient.moveCursor(inputMethodAbility.CURSOR_xxx, (err) => { try {
if (err === undefined) { InputClient.moveCursor(inputMethodAbility.CURSOR_xxx, (err) => {
console.error('moveCursor callback result---err: ' + err.msg); if (err) {
return; console.error('moveCursor err: ' + JSON.stringify(err));
} return;
}); }
console.info('moveCursor success');
});
} catch (err) {
console.error('moveCursor err: ' + JSON.stringify(err));
}
``` ```
### moveCursor<sup>9+</sup> ### moveCursor<sup>9+</sup>
...@@ -1867,11 +1904,19 @@ moveCursor(direction: number): Promise&lt;void&gt; ...@@ -1867,11 +1904,19 @@ moveCursor(direction: number): Promise&lt;void&gt;
```js ```js
async function InputMethodAbility() { async function InputMethodAbility() {
await InputClient.moveCursor(inputMethodAbility.CURSOR_xxx).then(async (err) => { try {
console.log('moveCursor success'); await InputClient.moveCursor(inputMethodEngine.CURSOR_xxx).then((err) => {
}).catch((err) => { if (err) {
console.error('moveCursor success err: ' + err.msg); console.log('moveCursor err: ' + JSON.stringify(err));
}); return;
}
console.log('moveCursor success');
}).catch((err) => {
console.error('moveCursor success err: ' + JSON.stringify(err));
});
} catch (e) {
console.log('moveCursor err: ' + JSON.stringify(err));
}
} }
``` ```
......
# 输入法框架错误码 # 输入法框架错误码
## 12800201 权限校验异常 ## 201 权限校验异常
### 错误信息 ### 错误信息
the permissions check fails. the permissions check fails.
...@@ -11,7 +11,7 @@ the permissions check fails. ...@@ -11,7 +11,7 @@ the permissions check fails.
### 处理步骤 ### 处理步骤
给应用配置相应的权限 给应用配置相应的权限
## 12800401 参数校验异常 ## 401 参数校验异常
### 错误信息 ### 错误信息
the parameters check fails. the parameters check fails.
...@@ -22,7 +22,7 @@ the parameters check fails. ...@@ -22,7 +22,7 @@ the parameters check fails.
### 处理步骤 ### 处理步骤
修改接口调用时传入的参数个数或者类型 修改接口调用时传入的参数个数或者类型
## 12800801 功能支持异常 ## 801 功能支持异常
### 错误信息 ### 错误信息
call unsupported api. call unsupported api.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册