提交 72c88a41 编写于 作者: H Hollokin

示例代码缩进2空格;if(err!==undefined)等直接改为if(err)即可

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 2e52d650
...@@ -38,9 +38,9 @@ Extension生命周期回调,在拉起Extension输入法应用时调用,执 ...@@ -38,9 +38,9 @@ Extension生命周期回调,在拉起Extension输入法应用时调用,执
```js ```js
class InputMethodExt extends InputMethodExtensionAbility { class InputMethodExt extends InputMethodExtensionAbility {
onCreate(want) { onCreate(want) {
console.log('onCreate, want:' + want.abilityName); console.log('onCreate, want:' + want.abilityName);
} }
} }
``` ```
...@@ -56,8 +56,8 @@ Extension生命周期回调,在销毁输入法应用时回调,执行资源 ...@@ -56,8 +56,8 @@ Extension生命周期回调,在销毁输入法应用时回调,执行资源
```js ```js
class InputMethodExt extends InputMethodExtensionAbility { class InputMethodExt extends InputMethodExtensionAbility {
onDestroy() { onDestroy() {
console.log('onDestroy'); console.log('onDestroy');
} }
} }
``` ```
...@@ -21,9 +21,9 @@ import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext'; ...@@ -21,9 +21,9 @@ import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext';
```js ```js
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility'; import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
class EntryAbility extends InputMethodExtensionAbility { class EntryAbility extends InputMethodExtensionAbility {
onCreate() { onCreate() {
let context = this.context; let context = this.context;
} }
} }
``` ```
...@@ -45,7 +45,7 @@ destroy(callback: AsyncCallback\<void>): void ...@@ -45,7 +45,7 @@ destroy(callback: AsyncCallback\<void>): void
```js ```js
this.context.destroy((err) => { this.context.destroy((err) => {
console.log('destroy result:' + JSON.stringify(err)); console.log('destroy result:' + JSON.stringify(err));
}); });
``` ```
...@@ -67,8 +67,8 @@ destroy(): Promise\<void>; ...@@ -67,8 +67,8 @@ destroy(): Promise\<void>;
```js ```js
this.context.destroy().then(() => { this.context.destroy().then(() => {
console.log('Succeed in destoring context.'); console.log('Succeed in destoring context.');
}).catch((error) => { }).catch((error) => {
console.log('Failed to destory context: ' + JSON.stringify(error)); console.log('Failed to destory context: ' + JSON.stringify(error));
}); });
``` ```
...@@ -128,26 +128,26 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea ...@@ -128,26 +128,26 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea
```js ```js
let im = inputMethod.getCurrentInputMethod(); let im = inputMethod.getCurrentInputMethod();
let prop = { let prop = {
packageName: im.packageName, packageName: im.packageName,
methodId: im.methodId, methodId: im.methodId,
name: im.packageName, name: im.packageName,
id: im.methodId, id: im.methodId,
extra: {} extra: {}
} }
try{ try{
inputMethod.switchInputMethod(prop, (err, result) => { inputMethod.switchInputMethod(prop, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in switching inputmethod.'); console.info('Succeeded in switching inputmethod.');
} else { } else {
console.error('Failed to switchInputMethod.'); console.error('Failed to switchInputMethod.');
} }
}); });
} catch(err) { } catch(err) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
} }
``` ```
## inputMethod.switchInputMethod<sup>9+</sup> ## inputMethod.switchInputMethod<sup>9+</sup>
...@@ -185,24 +185,24 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt; ...@@ -185,24 +185,24 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
```js ```js
let im = inputMethod.getCurrentInputMethod(); let im = inputMethod.getCurrentInputMethod();
let prop = { let prop = {
packageName: im.packageName, packageName: im.packageName,
methodId: im.methodId, methodId: im.methodId,
name: im.packageName, name: im.packageName,
id: im.methodId, id: im.methodId,
extra: {} extra: {}
} }
try { try {
inputMethod.switchInputMethod(prop).then((result) => { inputMethod.switchInputMethod(prop).then((result) => {
if (result) { if (result) {
console.info('Succeeded in switching inputmethod.'); console.info('Succeeded in switching inputmethod.');
} else { } else {
console.error('Failed to switchInputMethod.'); console.error('Failed to switchInputMethod.');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
} }
``` ```
...@@ -256,29 +256,29 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb ...@@ -256,29 +256,29 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
```js ```js
try { try {
inputMethod.switchCurrentInputMethodSubtype({ inputMethod.switchCurrentInputMethodSubtype({
id: "ServiceExtAbility", id: "ServiceExtAbility",
label: "", label: "",
name: "com.example.kikakeyboard", name: "com.example.kikakeyboard",
mode: "upper", mode: "upper",
locale: "", locale: "",
language: "", language: "",
icon: "", icon: "",
iconId: 0, iconId: 0,
extra: {} extra: {}
}, (err, result) => { }, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in switching currentInputMethodSubtype.'); console.info('Succeeded in switching currentInputMethodSubtype.');
} else { } else {
console.error('Failed to switchCurrentInputMethodSubtype'); console.error('Failed to switchCurrentInputMethodSubtype');
} }
}); });
} catch(err) { } catch(err) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -317,27 +317,27 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean& ...@@ -317,27 +317,27 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
```js ```js
try { try {
inputMethod.switchCurrentInputMethodSubtype({ inputMethod.switchCurrentInputMethodSubtype({
id: "ServiceExtAbility", id: "ServiceExtAbility",
label: "", label: "",
name: "com.example.kikakeyboard", name: "com.example.kikakeyboard",
mode: "upper", mode: "upper",
locale: "", locale: "",
language: "", language: "",
icon: "", icon: "",
iconId: 0, iconId: 0,
extra: {} extra: {}
}).then((result) => { }).then((result) => {
if (result) { if (result) {
console.info('Succeeded in switching currentInputMethodSubtype.'); console.info('Succeeded in switching currentInputMethodSubtype.');
} else { } else {
console.error('Failed to switchCurrentInputMethodSubtype.'); console.error('Failed to switchCurrentInputMethodSubtype.');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -394,19 +394,19 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -394,19 +394,19 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
let im = inputMethod.getCurrentInputMethod(); let im = inputMethod.getCurrentInputMethod();
let imSubType = inputMethod.getCurrentInputMethodSubtype(); let imSubType = inputMethod.getCurrentInputMethodSubtype();
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => { inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => {
if (err !== undefined) { if (err) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in switching currentInputMethodAndSubtype.'); console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else { } else {
console.error('Failed to switchCurrentInputMethodAndSubtype.'); console.error('Failed to switchCurrentInputMethodAndSubtype.');
} }
}); });
} catch (err) { } catch (err) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -448,17 +448,17 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -448,17 +448,17 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
let im = inputMethod.getCurrentInputMethod(); let im = inputMethod.getCurrentInputMethod();
let imSubType = inputMethod.getCurrentInputMethodSubtype(); let imSubType = inputMethod.getCurrentInputMethodSubtype();
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType).then((result) => { inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType).then((result) => {
if (result) { if (result) {
console.info('Succeeded in switching currentInputMethodAndSubtype.'); console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else { } else {
console.error('Failed to switchCurrentInputMethodAndSubtype.'); console.error('Failed to switchCurrentInputMethodAndSubtype.');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -683,21 +683,21 @@ attach(showKeyboard: boolean, textConfig: TextConfig, callback: AsyncCallback&lt ...@@ -683,21 +683,21 @@ attach(showKeyboard: boolean, textConfig: TextConfig, callback: AsyncCallback&lt
```js ```js
try { try {
let textConfig: inputMethod.TextConfig = { let textConfig: inputMethod.TextConfig = {
inputAttribute: { inputAttribute: {
textInputType: 0, textInputType: 0,
enterKeyType: 1 enterKeyType: 1
} }
}; };
inputMethodController.attach(true, textConfig, (err) => { inputMethodController.attach(true, textConfig, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to attach: ${JSON.stringify(err)}`); console.error(`Failed to attach: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in attaching the inputMethod.'); console.info('Succeeded in attaching the inputMethod.');
}); });
} catch(error) { } catch(error) {
console.error(`Failed to attach: ${JSON.stringify(error)}`); console.error(`Failed to attach: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -737,19 +737,19 @@ attach(showKeyboard: boolean, textConfig: TextConfig): Promise&lt;void&gt; ...@@ -737,19 +737,19 @@ attach(showKeyboard: boolean, textConfig: TextConfig): Promise&lt;void&gt;
```js ```js
try { try {
let textConfig: inputMethod.TextConfig = { let textConfig: inputMethod.TextConfig = {
inputAttribute: { inputAttribute: {
textInputType: 0, textInputType: 0,
enterKeyType: 1 enterKeyType: 1
} }
}; };
inputMethodController.attach(true, textConfig).then(() => { inputMethodController.attach(true, textConfig).then(() => {
console.info('Succeeded in attaching inputMethod.'); console.info('Succeeded in attaching inputMethod.');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to attach: ${JSON.stringify(err)}`); console.error(`Failed to attach: ${JSON.stringify(err)}`);
}) })
} catch(error) { } catch(error) {
console.error(`Failed to attach: ${JSON.stringify(error)}`); console.error(`Failed to attach: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -783,11 +783,11 @@ showTextInput(callback: AsyncCallback&lt;void&gt;): void ...@@ -783,11 +783,11 @@ showTextInput(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.showTextInput((err) => { inputMethodController.showTextInput((err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to showTextInput: ${JSON.stringify(err)}`); console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in showing the inputMethod.'); console.info('Succeeded in showing the inputMethod.');
}); });
``` ```
...@@ -821,9 +821,9 @@ showTextInput(): Promise&lt;void&gt; ...@@ -821,9 +821,9 @@ showTextInput(): Promise&lt;void&gt;
```js ```js
inputMethodController.showTextInput().then(() => { inputMethodController.showTextInput().then(() => {
console.info('Succeeded in showing text input.'); console.info('Succeeded in showing text input.');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to showTextInput: ${JSON.stringify(err)}`); console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
}); });
``` ```
...@@ -859,11 +859,11 @@ hideTextInput(callback: AsyncCallback&lt;void&gt;): void ...@@ -859,11 +859,11 @@ hideTextInput(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.hideTextInput((err) => { inputMethodController.hideTextInput((err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`); console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in hiding text input.'); console.info('Succeeded in hiding text input.');
}); });
``` ```
...@@ -932,11 +932,11 @@ detach(callback: AsyncCallback&lt;void&gt;): void ...@@ -932,11 +932,11 @@ detach(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.detach((err) => { inputMethodController.detach((err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to detach: ${JSON.stringify(err)}`); console.error(`Failed to detach: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in detaching inputMethod.'); console.info('Succeeded in detaching inputMethod.');
}); });
``` ```
...@@ -967,9 +967,9 @@ detach(): Promise&lt;void&gt; ...@@ -967,9 +967,9 @@ detach(): Promise&lt;void&gt;
```js ```js
inputMethodController.detach().then(() => { inputMethodController.detach().then(() => {
console.info('Succeeded in detaching inputMethod.'); console.info('Succeeded in detaching inputMethod.');
}).catch((error) => { }).catch((error) => {
console.error(`Failed to detach: ${JSON.stringify(error)}`); console.error(`Failed to detach: ${JSON.stringify(error)}`);
}); });
``` ```
...@@ -1004,16 +1004,16 @@ setCallingWindow(windowId: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1004,16 +1004,16 @@ setCallingWindow(windowId: number, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
let windowId: number = 2000; let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId, (err) => { inputMethodController.setCallingWindow(windowId, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`); console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in setting callingWindow.'); console.info('Succeeded in setting callingWindow.');
}); });
} catch(error) { } catch(error) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(error)}`); console.error(`Failed to setCallingWindow: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1053,14 +1053,14 @@ setCallingWindow(windowId: number): Promise&lt;void&gt; ...@@ -1053,14 +1053,14 @@ setCallingWindow(windowId: number): Promise&lt;void&gt;
```js ```js
try { try {
let windowId: number = 2000; let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId).then(() => { inputMethodController.setCallingWindow(windowId).then(() => {
console.info('Succeeded in setting callingWindow.'); console.info('Succeeded in setting callingWindow.');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`); console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
}) })
} catch(error) { } catch(error) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(error)}`); console.error(`Failed to setCallingWindow: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1095,15 +1095,15 @@ updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback&lt;void&gt;): void ...@@ -1095,15 +1095,15 @@ updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}, (err) => { inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`); console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in updating cursorInfo.'); console.info('Succeeded in updating cursorInfo.');
}); });
} catch(error) { } catch(error) {
console.error(`Failed to updateCursor: ${JSON.stringify(error)}`); console.error(`Failed to updateCursor: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1143,13 +1143,13 @@ updateCursor(cursorInfo: CursorInfo): Promise&lt;void&gt; ...@@ -1143,13 +1143,13 @@ updateCursor(cursorInfo: CursorInfo): Promise&lt;void&gt;
```js ```js
try { try {
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}).then(() => { inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}).then(() => {
console.info('Succeeded in updating cursorInfo.'); console.info('Succeeded in updating cursorInfo.');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`); console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
}) })
} catch(error) { } catch(error) {
console.error(`Failed to updateCursor: ${JSON.stringify(error)}`); console.error(`Failed to updateCursor: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1184,15 +1184,15 @@ changeSelection(text: string, start: number, end: number, callback: AsyncCallbac ...@@ -1184,15 +1184,15 @@ changeSelection(text: string, start: number, end: number, callback: AsyncCallbac
```js ```js
try { try {
inputMethodController.changeSelection('text', 0, 5, (err) => { inputMethodController.changeSelection('text', 0, 5, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`); console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in changing selection.'); console.info('Succeeded in changing selection.');
}); });
} catch(error) { } catch(error) {
console.error(`Failed to changeSelection: ${JSON.stringify(error)}`); console.error(`Failed to changeSelection: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1232,13 +1232,13 @@ changeSelection(text: string, start: number, end: number): Promise&lt;void&gt; ...@@ -1232,13 +1232,13 @@ changeSelection(text: string, start: number, end: number): Promise&lt;void&gt;
```js ```js
try { try {
inputMethodController.changeSelection('test', 0, 5).then(() => { inputMethodController.changeSelection('test', 0, 5).then(() => {
console.info('Succeeded in changing selection.'); console.info('Succeeded in changing selection.');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`); console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
}) })
} catch(error) { } catch(error) {
console.error(`Failed to changeSelection: ${JSON.stringify(error)}`); console.error(`Failed to changeSelection: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1271,15 +1271,15 @@ updateAttribute(attribute: InputAttribute, callback: AsyncCallback&lt;void&gt;): ...@@ -1271,15 +1271,15 @@ updateAttribute(attribute: InputAttribute, callback: AsyncCallback&lt;void&gt;):
```js ```js
try { try {
inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}, (err) => { inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`); console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in updating attribute.'); console.info('Succeeded in updating attribute.');
}); });
} catch(error) { } catch(error) {
console.error(`Failed to updateAttribute: ${JSON.stringify(error)}`); console.error(`Failed to updateAttribute: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1317,13 +1317,13 @@ updateAttribute(attribute: InputAttribute): Promise&lt;void&gt; ...@@ -1317,13 +1317,13 @@ updateAttribute(attribute: InputAttribute): Promise&lt;void&gt;
```js ```js
try { try {
inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}).then(() => { inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}).then(() => {
console.info('Succeeded in updating attribute.'); console.info('Succeeded in updating attribute.');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`); console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
}) })
} catch(error) { } catch(error) {
console.error(`Failed to updateAttribute: ${JSON.stringify(error)}`); console.error(`Failed to updateAttribute: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1356,19 +1356,19 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1356,19 +1356,19 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
try { try {
inputMethodController.stopInputSession((error, result) => { inputMethodController.stopInputSession((error, result) => {
if (error !== undefined) { if (error) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error)); console.error('Failed to stopInputSession: ' + JSON.stringify(error));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in stopping inputSession.'); console.info('Succeeded in stopping inputSession.');
} else { } else {
console.error('Failed to stopInputSession.'); console.error('Failed to stopInputSession.');
} }
}); });
} catch(error) { } catch(error) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error)); console.error('Failed to stopInputSession: ' + JSON.stringify(error));
} }
``` ```
...@@ -1401,17 +1401,17 @@ stopInputSession(): Promise&lt;boolean&gt; ...@@ -1401,17 +1401,17 @@ stopInputSession(): Promise&lt;boolean&gt;
```js ```js
try { try {
inputMethodController.stopInputSession().then((result) => { inputMethodController.stopInputSession().then((result) => {
if (result) { if (result) {
console.info('Succeeded in stopping inputSession.'); console.info('Succeeded in stopping inputSession.');
} else { } else {
console.error('Failed to stopInputSession.'); console.error('Failed to stopInputSession.');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to stopInputSession: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to stopInputSession: ' + JSON.stringify(err)); console.error('Failed to stopInputSession: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to stopInputSession: ' + JSON.stringify(err));
} }
``` ```
...@@ -1446,11 +1446,11 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -1446,11 +1446,11 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.showSoftKeyboard((err) => { inputMethodController.showSoftKeyboard((err) => {
if (err === undefined) { if (!err) {
console.info('Succeeded in showing softKeyboard.'); console.info('Succeeded in showing softKeyboard.');
} else { } else {
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err)); console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
} }
}) })
``` ```
...@@ -1485,9 +1485,9 @@ showSoftKeyboard(): Promise&lt;void&gt; ...@@ -1485,9 +1485,9 @@ showSoftKeyboard(): Promise&lt;void&gt;
```js ```js
inputMethodController.showSoftKeyboard().then(() => { inputMethodController.showSoftKeyboard().then(() => {
console.log('Succeeded in showing softKeyboard.'); console.log('Succeeded in showing softKeyboard.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err)); console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1522,11 +1522,11 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -1522,11 +1522,11 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.hideSoftKeyboard((err) => { inputMethodController.hideSoftKeyboard((err) => {
if (err === undefined) { if (!err) {
console.info('Succeeded in hiding softKeyboard.'); console.info('Succeeded in hiding softKeyboard.');
} else { } else {
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err)); console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
} }
}) })
``` ```
...@@ -1561,9 +1561,9 @@ hideSoftKeyboard(): Promise&lt;void&gt; ...@@ -1561,9 +1561,9 @@ hideSoftKeyboard(): Promise&lt;void&gt;
```js ```js
inputMethodController.hideSoftKeyboard().then(() => { inputMethodController.hideSoftKeyboard().then(() => {
console.log('Succeeded in hiding softKeyboard.'); console.log('Succeeded in hiding softKeyboard.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err)); console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1591,15 +1591,15 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1591,15 +1591,15 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
inputMethodController.stopInput((error, result) => { inputMethodController.stopInput((error, result) => {
if (error !== undefined) { if (error) {
console.error('Failed to stopInput: ' + JSON.stringify(error)); console.error('Failed to stopInput: ' + JSON.stringify(error));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in stopping input.'); console.info('Succeeded in stopping input.');
} else { } else {
console.error('Failed to stopInput.'); console.error('Failed to stopInput.');
} }
}); });
``` ```
...@@ -1627,13 +1627,13 @@ stopInput(): Promise&lt;boolean&gt; ...@@ -1627,13 +1627,13 @@ stopInput(): Promise&lt;boolean&gt;
```js ```js
inputMethodController.stopInput().then((result) => { inputMethodController.stopInput().then((result) => {
if (result) { if (result) {
console.info('Succeeded in stopping input.'); console.info('Succeeded in stopping input.');
} else { } else {
console.error('Failed to stopInput.'); console.error('Failed to stopInput.');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to stopInput: ' + err); console.error('Failed to stopInput: ' + err);
}) })
``` ```
...@@ -1664,11 +1664,11 @@ on(type: 'insertText', callback: (text: string) => void): void; ...@@ -1664,11 +1664,11 @@ on(type: 'insertText', callback: (text: string) => void): void;
```js ```js
try { try {
inputMethodController.on('insertText', (text) => { inputMethodController.on('insertText', (text) => {
console.info(`Succeeded in subscribing insertText: ${text}`); console.info(`Succeeded in subscribing insertText: ${text}`);
}); });
} catch(error) { } catch(error) {
console.error(`Failed to subscribe insertText: ${JSON.stringify(error)}`); console.error(`Failed to subscribe insertText: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1719,19 +1719,19 @@ on(type: 'deleteLeft' | 'deleteRight', callback: (length: number) => void): void ...@@ -1719,19 +1719,19 @@ on(type: 'deleteLeft' | 'deleteRight', callback: (length: number) => void): void
```js ```js
try { try {
inputMethodController.on('deleteLeft', (length) => { inputMethodController.on('deleteLeft', (length) => {
console.info(`Succeeded in subscribing deleteLeft, length: ${length}`); console.info(`Succeeded in subscribing deleteLeft, length: ${length}`);
}); });
} catch(error) { } catch(error) {
console.error(`Failed to subscribe deleteLeft: ${JSON.stringify(error)}`); console.error(`Failed to subscribe deleteLeft: ${JSON.stringify(error)}`);
} }
try { try {
inputMethodController.on('deleteRight', (length) => { inputMethodController.on('deleteRight', (length) => {
console.info(`Succeeded in subscribing deleteRight, length: ${length}`); console.info(`Succeeded in subscribing deleteRight, length: ${length}`);
}); });
} catch(error) { } catch(error) {
console.error(`Failed to subscribe deleteRight: ${JSON.stringify(error)}`); console.error(`Failed to subscribe deleteRight: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1783,11 +1783,11 @@ on(type: 'sendKeyboardStatus', callback: (keyBoardStatus: KeyboardStatus) => voi ...@@ -1783,11 +1783,11 @@ on(type: 'sendKeyboardStatus', callback: (keyBoardStatus: KeyboardStatus) => voi
```js ```js
try { try {
inputMethodController.on('sendKeyboardStatus', (keyBoardStatus) => { inputMethodController.on('sendKeyboardStatus', (keyBoardStatus) => {
console.info(`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus: ${keyBoardStatus}`); console.info(`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus: ${keyBoardStatus}`);
}); });
} catch(error) { } catch(error) {
console.error(`Failed to subscribe sendKeyboardStatus: ${JSON.stringify(error)}`); console.error(`Failed to subscribe sendKeyboardStatus: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1838,11 +1838,11 @@ on(type: 'sendFunctionKey', callback: (functionKey: FunctionKey) => void): void ...@@ -1838,11 +1838,11 @@ on(type: 'sendFunctionKey', callback: (functionKey: FunctionKey) => void): void
```js ```js
try { try {
inputMethodController.on('sendFunctionKey', (functionKey) => { inputMethodController.on('sendFunctionKey', (functionKey) => {
console.info(`Succeeded in subscribing sendFunctionKey, functionKey.enterKeyType: ${functionKey.enterKeyType}`); console.info(`Succeeded in subscribing sendFunctionKey, functionKey.enterKeyType: ${functionKey.enterKeyType}`);
}); });
} catch(error) { } catch(error) {
console.error(`Failed to subscribe sendFunctionKey: ${JSON.stringify(error)}`); console.error(`Failed to subscribe sendFunctionKey: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1893,11 +1893,11 @@ on(type: 'moveCursor', callback: (direction: Direction) => void): void ...@@ -1893,11 +1893,11 @@ on(type: 'moveCursor', callback: (direction: Direction) => void): void
```js ```js
try { try {
inputMethodController.on('moveCursor', (direction) => { inputMethodController.on('moveCursor', (direction) => {
console.info(`Succeeded in subscribing moveCursor, direction: ${direction}`); console.info(`Succeeded in subscribing moveCursor, direction: ${direction}`);
}); });
} catch(error) { } catch(error) {
console.error(`Failed to subscribe moveCursor: ${JSON.stringify(error)}`); console.error(`Failed to subscribe moveCursor: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1948,11 +1948,11 @@ on(type: 'handleExtendAction', callback: (action: ExtendAction) => void): void ...@@ -1948,11 +1948,11 @@ on(type: 'handleExtendAction', callback: (action: ExtendAction) => void): void
```js ```js
try { try {
inputMethodController.on('handleExtendAction', (action) => { inputMethodController.on('handleExtendAction', (action) => {
console.info(`Succeeded in subscribing handleExtendAction, action: ${action}`); console.info(`Succeeded in subscribing handleExtendAction, action: ${action}`);
}); });
} catch(error) { } catch(error) {
console.error(`Failed to subscribe handleExtendAction: ${JSON.stringify(error)}`); console.error(`Failed to subscribe handleExtendAction: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -1995,7 +1995,7 @@ on(type: 'selectByRange', callback: Callback&lt;Range&gt;): void ...@@ -1995,7 +1995,7 @@ on(type: 'selectByRange', callback: Callback&lt;Range&gt;): void
```js ```js
inputMethodController.on('selectByRange', (range) => { inputMethodController.on('selectByRange', (range) => {
console.info('Succeeded in subscribing selectByRange: start: ' + range.start + " , end: " + range.end); console.info('Succeeded in subscribing selectByRange: start: ' + range.start + " , end: " + range.end);
}); });
``` ```
...@@ -2038,7 +2038,7 @@ on(type: 'selectByMovement', callback: Callback&lt;Movement&gt;): void ...@@ -2038,7 +2038,7 @@ on(type: 'selectByMovement', callback: Callback&lt;Movement&gt;): void
```js ```js
inputMethodController.on('selectByMovement', (movement) => { inputMethodController.on('selectByMovement', (movement) => {
console.info('Succeeded in subscribing selectByMovement: direction: ' + movement.direction); console.info('Succeeded in subscribing selectByMovement: direction: ' + movement.direction);
}); });
``` ```
...@@ -2085,7 +2085,7 @@ on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, input ...@@ -2085,7 +2085,7 @@ on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, input
```js ```js
inputMethodSetting.on('imeChange', (inputMethodProperty, inputMethodSubtype) => { inputMethodSetting.on('imeChange', (inputMethodProperty, inputMethodSubtype) => {
console.info('Succeeded in subscribing imeChange: inputMethodProperty: ' + JSON.stringify(inputMethodProperty) + " , inputMethodSubtype: " + JSON.stringify(inputMethodSubtype)); console.info('Succeeded in subscribing imeChange: inputMethodProperty: ' + JSON.stringify(inputMethodProperty) + " , inputMethodSubtype: " + JSON.stringify(inputMethodSubtype));
}); });
``` ```
...@@ -2138,22 +2138,22 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async ...@@ -2138,22 +2138,22 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
```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', name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard', id: 'com.example.kikakeyboard',
extra:{} extra:{}
} }
try { try {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => {
if (err !== undefined) { if (err) {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in listing inputMethodSubtype.'); console.log('Succeeded in listing inputMethodSubtype.');
}); });
} catch (err) { } catch (err) {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -2190,20 +2190,20 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr ...@@ -2190,20 +2190,20 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr
```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', name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard', id: 'com.example.kikakeyboard',
extra:{} extra:{}
} }
try { try {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => {
console.info('Succeeded in listing inputMethodSubtype.'); console.info('Succeeded in listing inputMethodSubtype.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -2234,15 +2234,15 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub ...@@ -2234,15 +2234,15 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
```js ```js
try { try {
inputMethodSetting.listCurrentInputMethodSubtype((err, data) => { inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err !== undefined) { if (err) {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in listing currentInputMethodSubtype.'); console.log('Succeeded in listing currentInputMethodSubtype.');
}); });
} catch(err) { } catch(err) {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -2273,13 +2273,13 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt; ...@@ -2273,13 +2273,13 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
```js ```js
try { try {
inputMethodSetting.listCurrentInputMethodSubtype().then((data) => { inputMethodSetting.listCurrentInputMethodSubtype().then((data) => {
console.info('Succeeded in listing currentInputMethodSubtype.'); console.info('Succeeded in listing currentInputMethodSubtype.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
} }
``` ```
...@@ -2311,15 +2311,15 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod ...@@ -2311,15 +2311,15 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
```js ```js
try { try {
inputMethodSetting.getInputMethods(true, (err,data) => { inputMethodSetting.getInputMethods(true, (err,data) => {
if (err !== undefined) { if (err) {
console.error('Failed to getInputMethods: ' + JSON.stringify(err)); console.error('Failed to getInputMethods: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in getting inputMethods.'); console.log('Succeeded in getting inputMethods.');
}); });
} catch (err) { } catch (err) {
console.error('Failed to getInputMethods: ' + JSON.stringify(err)); console.error('Failed to getInputMethods: ' + JSON.stringify(err));
} }
``` ```
...@@ -2356,13 +2356,13 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt ...@@ -2356,13 +2356,13 @@ 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('Succeeded in getting inputMethods.'); console.info('Succeeded in getting inputMethods.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to getInputMethods: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to getInputMethods: ' + JSON.stringify(err)); console.error('Failed to getInputMethods: ' + JSON.stringify(err));
})
} catch(err) {
console.error('Failed to getInputMethods: ' + JSON.stringify(err));
} }
``` ```
...@@ -2392,15 +2392,15 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2392,15 +2392,15 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
try { try {
inputMethodSetting.showOptionalInputMethods((err, data) => { inputMethodSetting.showOptionalInputMethods((err, data) => {
if (err !== undefined) { if (err) {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err)); console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in showing optionalInputMethods.'); console.info('Succeeded in showing optionalInputMethods.');
}); });
} catch (err) { } catch (err) {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err)); console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
} }
``` ```
...@@ -2430,9 +2430,9 @@ showOptionalInputMethods(): Promise&lt;boolean&gt; ...@@ -2430,9 +2430,9 @@ showOptionalInputMethods(): Promise&lt;boolean&gt;
```js ```js
inputMethodSetting.showOptionalInputMethods().then((data) => { inputMethodSetting.showOptionalInputMethods().then((data) => {
console.info('Succeeded in showing optionalInputMethods.'); console.info('Succeeded in showing optionalInputMethods.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err)); console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
}) })
``` ```
...@@ -2458,11 +2458,11 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;) ...@@ -2458,11 +2458,11 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
```js ```js
inputMethodSetting.listInputMethod((err,data) => { inputMethodSetting.listInputMethod((err,data) => {
if (err !== undefined) { if (err) {
console.error('Failed to listInputMethod: ' + JSON.stringify(err)); console.error('Failed to listInputMethod: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in listing inputMethod.'); console.log('Succeeded in listing inputMethod.');
}); });
``` ```
...@@ -2488,9 +2488,9 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt; ...@@ -2488,9 +2488,9 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
```js ```js
inputMethodSetting.listInputMethod().then((data) => { inputMethodSetting.listInputMethod().then((data) => {
console.info('Succeeded in listing inputMethod.'); console.info('Succeeded in listing inputMethod.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to listInputMethod: ' + JSON.stringify(err)); console.error('Failed to listInputMethod: ' + JSON.stringify(err));
}) })
``` ```
...@@ -2516,11 +2516,11 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void ...@@ -2516,11 +2516,11 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodSetting.displayOptionalInputMethod((err) => { inputMethodSetting.displayOptionalInputMethod((err) => {
if (err !== undefined) { if (err) {
console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err)); console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in displaying optionalInputMethod.'); console.info('Succeeded in displaying optionalInputMethod.');
}); });
``` ```
...@@ -2546,8 +2546,8 @@ displayOptionalInputMethod(): Promise&lt;void&gt; ...@@ -2546,8 +2546,8 @@ displayOptionalInputMethod(): Promise&lt;void&gt;
```js ```js
inputMethodSetting.displayOptionalInputMethod().then(() => { inputMethodSetting.displayOptionalInputMethod().then(() => {
console.info('Succeeded in displaying optionalInputMethod.'); console.info('Succeeded in displaying optionalInputMethod.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err)); console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err));
}) })
``` ```
...@@ -165,8 +165,8 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli ...@@ -165,8 +165,8 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
```js ```js
inputMethodEngine.getInputMethodEngine().on('inputStart', (kbController, textClient) => { inputMethodEngine.getInputMethodEngine().on('inputStart', (kbController, textClient) => {
let keyboardController = kbController; let keyboardController = kbController;
let textInputClient = textClient; let textInputClient = textClient;
}); });
``` ```
...@@ -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.getInputMethodEngine().off('inputStart', (kbController, textInputClient) => { inputMethodEngine.getInputMethodEngine().off('inputStart', (kbController, textInputClient) => {
console.log('delete inputStart notification.'); console.log('delete inputStart notification.');
}); });
``` ```
...@@ -212,10 +212,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void ...@@ -212,10 +212,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
```js ```js
inputMethodEngine.getInputMethodEngine().on('keyboardShow', () => { inputMethodEngine.getInputMethodEngine().on('keyboardShow', () => {
console.log('inputMethodEngine keyboardShow.'); console.log('inputMethodEngine keyboardShow.');
}); });
inputMethodEngine.getInputMethodEngine().on('keyboardHide', () => { inputMethodEngine.getInputMethodEngine().on('keyboardHide', () => {
console.log('inputMethodEngine keyboardHide.'); console.log('inputMethodEngine keyboardHide.');
}); });
``` ```
...@@ -264,8 +264,8 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: ...@@ -264,8 +264,8 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient:
```js ```js
inputMethodEngine.getInputMethodAbility().on('inputStart', (kbController, client) => { inputMethodEngine.getInputMethodAbility().on('inputStart', (kbController, client) => {
let keyboardController = kbController; let keyboardController = kbController;
let inputClient = client; let inputClient = client;
}); });
``` ```
...@@ -309,7 +309,7 @@ on(type: 'inputStop', callback: () => void): void ...@@ -309,7 +309,7 @@ on(type: 'inputStop', callback: () => void): void
```js ```js
inputMethodEngine.getInputMethodAbility().on('inputStop', () => { inputMethodEngine.getInputMethodAbility().on('inputStop', () => {
console.log('inputMethodAbility inputStop'); console.log('inputMethodAbility inputStop');
}); });
``` ```
...@@ -332,7 +332,7 @@ off(type: 'inputStop', callback: () => void): void ...@@ -332,7 +332,7 @@ off(type: 'inputStop', callback: () => void): void
```js ```js
inputMethodEngine.getInputMethodAbility().off('inputStop', () => { inputMethodEngine.getInputMethodAbility().off('inputStop', () => {
console.log('inputMethodAbility delete inputStop notification.'); console.log('inputMethodAbility delete inputStop notification.');
}); });
``` ```
...@@ -355,7 +355,7 @@ on(type: 'setCallingWindow', callback: (wid: number) => void): void ...@@ -355,7 +355,7 @@ on(type: 'setCallingWindow', callback: (wid: number) => void): void
```js ```js
inputMethodEngine.getInputMethodAbility().on('setCallingWindow', (wid) => { inputMethodEngine.getInputMethodAbility().on('setCallingWindow', (wid) => {
console.log('inputMethodAbility setCallingWindow'); console.log('inputMethodAbility setCallingWindow');
}); });
``` ```
...@@ -378,7 +378,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void ...@@ -378,7 +378,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void
```js ```js
inputMethodEngine.getInputMethodAbility().off('setCallingWindow', () => { inputMethodEngine.getInputMethodAbility().off('setCallingWindow', () => {
console.log('inputMethodAbility delete setCallingWindow notification.'); console.log('inputMethodAbility delete setCallingWindow notification.');
}); });
``` ```
...@@ -401,10 +401,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void ...@@ -401,10 +401,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
```js ```js
inputMethodEngine.getInputMethodAbility().on('keyboardShow', () => { inputMethodEngine.getInputMethodAbility().on('keyboardShow', () => {
console.log('InputMethodAbility keyboardShow.'); console.log('InputMethodAbility keyboardShow.');
}); });
inputMethodEngine.getInputMethodAbility().on('keyboardHide', () => { inputMethodEngine.getInputMethodAbility().on('keyboardHide', () => {
console.log('InputMethodAbility keyboardHide.'); console.log('InputMethodAbility keyboardHide.');
}); });
``` ```
...@@ -427,10 +427,10 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void ...@@ -427,10 +427,10 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
```js ```js
inputMethodEngine.getInputMethodAbility().off('keyboardShow', () => { inputMethodEngine.getInputMethodAbility().off('keyboardShow', () => {
console.log('InputMethodAbility delete keyboardShow notification.'); console.log('InputMethodAbility delete keyboardShow notification.');
}); });
inputMethodEngine.getInputMethodAbility().off('keyboardHide', () => { inputMethodEngine.getInputMethodAbility().off('keyboardHide', () => {
console.log('InputMethodAbility delete keyboardHide notification.'); console.log('InputMethodAbility delete keyboardHide notification.');
}); });
``` ```
...@@ -453,7 +453,7 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi ...@@ -453,7 +453,7 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi
```js ```js
inputMethodEngine.getInputMethodAbility().on('setSubtype', (inputMethodSubtype) => { inputMethodEngine.getInputMethodAbility().on('setSubtype', (inputMethodSubtype) => {
console.log('InputMethodAbility setSubtype.'); console.log('InputMethodAbility setSubtype.');
}); });
``` ```
...@@ -476,7 +476,7 @@ off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => v ...@@ -476,7 +476,7 @@ off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => v
```js ```js
inputMethodEngine.getInputMethodAbility().off('setSubtype', () => { inputMethodEngine.getInputMethodAbility().off('setSubtype', () => {
console.log('InputMethodAbility delete setSubtype notification.'); console.log('InputMethodAbility delete setSubtype notification.');
}); });
``` ```
...@@ -513,7 +513,7 @@ let panelInfo: inputMethodEngine.PanelInfo = { ...@@ -513,7 +513,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
} }
try { try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => { inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) { if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err)); console.log('Failed to create panel, err: ' + JSON.stringify(err));
return; return;
} }
...@@ -590,7 +590,7 @@ let panelInfo: inputMethodEngine.PanelInfo = { ...@@ -590,7 +590,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
} }
try { try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => { inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) { if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err)); console.log('Failed to create panel, err: ' + JSON.stringify(err));
return; return;
} }
...@@ -642,7 +642,7 @@ let panelInfo: inputMethodEngine.PanelInfo = { ...@@ -642,7 +642,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
} }
try { try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => { inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) { if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err)); console.log('Failed to create panel, err: ' + JSON.stringify(err));
return; return;
} }
...@@ -687,14 +687,14 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void ...@@ -687,14 +687,14 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
```js ```js
inputMethodEngine.getKeyboardDelegate().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;
}); });
inputMethodEngine.getKeyboardDelegate().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;
}); });
``` ```
...@@ -717,12 +717,12 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void ...@@ -717,12 +717,12 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
```js ```js
inputMethodEngine.getKeyboardDelegate().off('keyUp', (keyEvent) => { inputMethodEngine.getKeyboardDelegate().off('keyUp', (keyEvent) => {
console.log('delete keyUp notification.'); console.log('delete keyUp notification.');
return true; return true;
}); });
inputMethodEngine.getKeyboardDelegate().off('keyDown', (keyEvent) => { inputMethodEngine.getKeyboardDelegate().off('keyDown', (keyEvent) => {
console.log('delete keyDown notification.'); console.log('delete keyDown notification.');
return true; return true;
}); });
``` ```
...@@ -745,9 +745,9 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = ...@@ -745,9 +745,9 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
```js ```js
inputMethodEngine.getKeyboardDelegate().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);
}); });
``` ```
...@@ -771,7 +771,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y: number, height: numbe ...@@ -771,7 +771,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y: number, height: numbe
```js ```js
inputMethodEngine.getKeyboardDelegate().off('cursorContextChange', (x, y, height) => { inputMethodEngine.getKeyboardDelegate().off('cursorContextChange', (x, y, height) => {
console.log('delete cursorContextChange notification.'); console.log('delete cursorContextChange notification.');
}); });
``` ```
### on('selectionChange') ### on('selectionChange')
...@@ -793,10 +793,10 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi ...@@ -793,10 +793,10 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
```js ```js
inputMethodEngine.getKeyboardDelegate().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);
console.log('inputMethodEngine beforeEach selectionChange newEnd:' + newEnd); console.log('inputMethodEngine beforeEach selectionChange newEnd:' + newEnd);
}); });
``` ```
...@@ -837,13 +837,13 @@ on(type: 'textChange', callback: (text: string) => void): void ...@@ -837,13 +837,13 @@ on(type: 'textChange', callback: (text: string) => void): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| 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) => {
console.log('inputMethodEngine textChange. text:' + text); console.log('inputMethodEngine textChange. text:' + text);
}); });
``` ```
...@@ -866,7 +866,7 @@ off(type: 'textChange', callback?: (text: string) => void): void ...@@ -866,7 +866,7 @@ off(type: 'textChange', callback?: (text: string) => void): void
```js ```js
inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => { inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
console.log('delete textChange notification. text:' + text); console.log('delete textChange notification. text:' + text);
}); });
``` ```
...@@ -1017,6 +1017,7 @@ try { ...@@ -1017,6 +1017,7 @@ try {
resize(width: number, height: number, callback: AsyncCallback\<void>): void resize(width: number, height: number, callback: AsyncCallback\<void>): void
改变当前面板大小,使用callback异步回调。 改变当前面板大小,使用callback异步回调。
面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。 面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1088,6 +1089,7 @@ try { ...@@ -1088,6 +1089,7 @@ try {
moveTo(x: number, y: number, callback: AsyncCallback\<void>): void moveTo(x: number, y: number, callback: AsyncCallback\<void>): void
移动面板位置,使用callback异步回调。 移动面板位置,使用callback异步回调。
对FLG_FIXED状态的panel不产生实际移动效果。 对FLG_FIXED状态的panel不产生实际移动效果。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1260,7 +1262,7 @@ promise.then(() => { ...@@ -1260,7 +1262,7 @@ promise.then(() => {
on(type: 'show' | 'hide', callback: () => void): void on(type: 'show' | 'hide', callback: () => void): void
监听当前面板状态,可监听面板类型为show或者hide, 使用callback异步回调。 监听当前面板状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1283,7 +1285,7 @@ panel.on('show', () => { ...@@ -1283,7 +1285,7 @@ panel.on('show', () => {
off(type: 'show' | 'hide', callback?: () => void): void off(type: 'show' | 'hide', callback?: () => void): void
取消监听当前面板状态,可取消监听的面板类型为show或者hide,使用callback异步回调。 取消监听当前面板状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1351,11 +1353,11 @@ hide(callback: AsyncCallback&lt;void&gt;): void ...@@ -1351,11 +1353,11 @@ hide(callback: AsyncCallback&lt;void&gt;): void
```js ```js
keyboardController.hide((err) => { keyboardController.hide((err) => {
if (err !== undefined) { if (err) {
console.error('Failed to hide keyboard: ' + JSON.stringify(err)); console.error('Failed to hide keyboard: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in hiding keyboard.'); console.log('Succeeded in hiding keyboard.');
}); });
``` ```
...@@ -1385,9 +1387,9 @@ hide(): Promise&lt;void&gt; ...@@ -1385,9 +1387,9 @@ hide(): Promise&lt;void&gt;
```js ```js
keyboardController.hide().then(() => { keyboardController.hide().then(() => {
console.info('Succeeded in hiding keyboard.'); console.info('Succeeded in hiding keyboard.');
}).catch((err) => { }).catch((err) => {
console.info('Failed to hide keyboard: ' + JSON.stringify(err)); console.info('Failed to hide keyboard: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1413,11 +1415,11 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -1413,11 +1415,11 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js ```js
keyboardController.hideKeyboard((err) => { keyboardController.hideKeyboard((err) => {
if (err !== undefined) { if (err) {
console.error('Failed to hide Keyboard: ' + JSON.stringify(err)); console.error('Failed to hide Keyboard: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in hiding keyboard.'); console.log('Succeeded in hiding keyboard.');
}); });
``` ```
...@@ -1443,9 +1445,9 @@ hideKeyboard(): Promise&lt;void&gt; ...@@ -1443,9 +1445,9 @@ hideKeyboard(): Promise&lt;void&gt;
```js ```js
keyboardController.hideKeyboard().then(() => { keyboardController.hideKeyboard().then(() => {
console.info('Succeeded in hiding keyboard.'); console.info('Succeeded in hiding keyboard.');
}).catch((err) => { }).catch((err) => {
console.info('Failed to hide Keyboard: ' + JSON.stringify(err)); console.info('Failed to hide Keyboard: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1528,19 +1530,19 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1528,19 +1530,19 @@ 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 !== undefined) { if (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err)); console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in sending key function. '); 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('sendKeyFunction err: ' + JSON.stringify(err));
} }
``` ```
...@@ -1577,17 +1579,17 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt; ...@@ -1577,17 +1579,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('Succeeded in sending key function. '); 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('Failed to sendKeyFunction:' + JSON.stringify(err)); console.error('Failed to sendKeyFunction:' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err)); console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
} }
``` ```
...@@ -1620,15 +1622,15 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1620,15 +1622,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 !== undefined) { if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in getting forward, text: ' + text); console.log('Succeeded in getting forward, text: ' + text);
}); });
} catch (err) { } catch (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1666,13 +1668,13 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -1666,13 +1668,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('Succeeded in getting forward, text: ' + text); console.info('Succeeded in getting forward, text: ' + text);
}).catch((err) => { }).catch((err) => {
console.error('Failed to getForward: ' + JSON.stringify(err));
});
} catch (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
});
} catch (err) {
console.error('Failed to getForward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1705,15 +1707,15 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1705,15 +1707,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 !== undefined) { if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in getting backward, text: ' + text); console.log('Succeeded in getting backward, text: ' + text);
}); });
} catch (err) { } catch (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1751,13 +1753,13 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -1751,13 +1753,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('Succeeded in getting backward, text: ' + text); console.info('Succeeded in getting backward, text: ' + text);
}).catch((err) => { }).catch((err) => {
console.error('Failed to getForward: ' + JSON.stringify(err));
});
} catch (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
});
} catch (err) {
console.error('Failed to getForward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1790,19 +1792,19 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1790,19 +1792,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 !== undefined) { if (err) {
console.error('Failed to delete forward: ' + JSON.stringify(err)); console.error('Failed to delete forward: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in deleting forward. '); console.info('Succeeded in deleting forward. ');
} else { } else {
console.error('Failed to delete forward: ' + JSON.stringify(err)); console.error('Failed to delete forward: ' + JSON.stringify(err));
} }
}); });
} catch (err) { } catch (err) {
console.error('Failed to delete forward: ' + JSON.stringify(err)); console.error('Failed to delete forward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1840,17 +1842,17 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -1840,17 +1842,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('Succeeded 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: ' + JSON.stringify(err));
});
} catch (err) {
console.error('Failed to delete Forward: ' + JSON.stringify(err)); console.error('Failed to delete Forward: ' + JSON.stringify(err));
});
} catch (err) {
console.error('Failed to delete Forward: ' + JSON.stringify(err));
} }
``` ```
...@@ -1883,19 +1885,19 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1883,19 +1885,19 @@ 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 !== undefined) { if (err) {
console.error('Failed to delete Backward: ' + JSON.stringify(err)); console.error('Failed to delete Backward: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in deleting backward. '); console.info('Succeeded in deleting backward. ');
} else { } else {
console.error('Failed to delete Backward: ' + JSON.stringify(err)); console.error('Failed to delete Backward: ' + JSON.stringify(err));
} }
}); });
} catch (err) { } catch (err) {
console.error('deleteBackward err: ' + JSON.stringify(err)); console.error('deleteBackward err: ' + JSON.stringify(err));
} }
``` ```
...@@ -1933,13 +1935,13 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -1933,13 +1935,13 @@ 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('Succeeded in deleting backward. '); console.info('Succeeded in deleting backward. ');
} else { } else {
console.error('Failed to deleteBackward. '); console.error('Failed to deleteBackward. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to deleteBackward: ' + JSON.stringify(err)); console.error('Failed to deleteBackward: ' + JSON.stringify(err));
}); });
``` ```
...@@ -1971,15 +1973,15 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1971,15 +1973,15 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
inputClient.insertText('test', (err, result) => { inputClient.insertText('test', (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to insertText: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in inserting text. '); console.info('Succeeded in inserting text. ');
} else { } else {
console.error('Failed to insertText. '); console.error('Failed to insertText. ');
} }
}); });
``` ```
...@@ -2016,17 +2018,17 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -2016,17 +2018,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('Succeeded in inserting text. '); console.info('Succeeded in inserting text. ');
} else { } else {
console.error('Failed to insertText. '); console.error('Failed to insertText. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to insertText: ' + JSON.stringify(err));
});
} catch (err) {
console.error('Failed to insertText: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
});
} catch (err) {
console.error('Failed to insertText: ' + JSON.stringify(err));
} }
``` ```
...@@ -2056,12 +2058,12 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -2056,12 +2058,12 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
```js ```js
inputClient.getEditorAttribute((err, editorAttribute) => { inputClient.getEditorAttribute((err, editorAttribute) => {
if (err !== undefined) { if (err) {
console.error('Failed to getEditorAttribute: ' + 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));
console.log('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType)); console.log('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
}); });
``` ```
...@@ -2091,10 +2093,10 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -2091,10 +2093,10 @@ 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('Failed to getEditorAttribute: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2125,15 +2127,15 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -2125,15 +2127,15 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err) => { inputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err) => {
if (err !== undefined) { if (err) {
console.error('Failed to moveCursor: ' + JSON.stringify(err)); console.error('Failed to moveCursor: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in moving cursor.'); console.info('Succeeded in moving cursor.');
}); });
} catch (err) { } catch (err) {
console.error('Failed to moveCursor: ' + JSON.stringify(err)); console.error('Failed to moveCursor: ' + JSON.stringify(err));
} }
``` ```
...@@ -2169,13 +2171,13 @@ moveCursor(direction: number): Promise&lt;void&gt; ...@@ -2169,13 +2171,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('Succeeded in moving cursor.'); console.log('Succeeded in moving cursor.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to moveCursor: ' + JSON.stringify(err)); console.error('Failed to moveCursor: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log('Failed to moveCursor: ' + JSON.stringify(err)); console.log('Failed to moveCursor: ' + JSON.stringify(err));
} }
``` ```
...@@ -2207,15 +2209,15 @@ selectByRange(range: Range, callback: AsyncCallback&lt;void&gt;): void ...@@ -2207,15 +2209,15 @@ selectByRange(range: Range, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputClient.selectByRange({start: 0, end: 1}, (err) => { inputClient.selectByRange({start: 0, end: 1}, (err) => {
if (err !== undefined) { if (err) {
console.error('Failed to selectByRange: ${err.message}'); console.error('Failed to selectByRange: ${err.message}');
return; return;
} }
console.info('Succeeded in selecting by range.'); console.info('Succeeded in selecting by range.');
}); });
} catch (err) { } catch (err) {
console.error('Failed to selectByRange: ${err.message}'); console.error('Failed to selectByRange: ${err.message}');
} }
``` ```
...@@ -2252,13 +2254,13 @@ selectByRange(range: Range): Promise&lt;void&gt; ...@@ -2252,13 +2254,13 @@ selectByRange(range: Range): Promise&lt;void&gt;
```js ```js
try { try {
inputClient.selectByRange({start: 0, end:1}).then(() => { inputClient.selectByRange({start: 0, end:1}).then(() => {
console.log('Succeeded in selecting by range.'); console.log('Succeeded in selecting by range.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to selectByRange: ${err.message}'); console.error('Failed to selectByRange: ${err.message}');
}); });
} catch (err) { } catch (err) {
console.log('Failed to selectByRange: ${err.message}'); console.log('Failed to selectByRange: ${err.message}');
} }
``` ```
...@@ -2290,15 +2292,15 @@ selectByMovement(movement: Movement, callback: AsyncCallback&lt;void&gt;): void ...@@ -2290,15 +2292,15 @@ selectByMovement(movement: Movement, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputClient.selectByMovement({direction: 1}, (err) => { inputClient.selectByMovement({direction: 1}, (err) => {
if (err !== undefined) { if (err) {
console.error('Failed to selectByMovement: ${err.message}'); console.error('Failed to selectByMovement: ${err.message}');
return; return;
} }
console.info('Succeeded in selecting by movement.'); console.info('Succeeded in selecting by movement.');
}); });
} catch (err) { } catch (err) {
console.error('Failed to selectByMovement: ${err.message}'); console.error('Failed to selectByMovement: ${err.message}');
} }
``` ```
...@@ -2335,13 +2337,13 @@ selectByMovement(movement: Movement): Promise&lt;void&gt; ...@@ -2335,13 +2337,13 @@ selectByMovement(movement: Movement): Promise&lt;void&gt;
```js ```js
try { try {
inputClient.selectByMovement({direction: 1}).then(() => { inputClient.selectByMovement({direction: 1}).then(() => {
console.log('Succeeded in selecting by movement.'); console.log('Succeeded in selecting by movement.');
}).catch((err) => { }).catch((err) => {
console.error('Failed to selectByMovement: ${err.message}'); console.error('Failed to selectByMovement: ${err.message}');
}); });
} catch (err) { } catch (err) {
console.log('Failed to selectByMovement: ${err.message}'); console.log('Failed to selectByMovement: ${err.message}');
} }
``` ```
...@@ -2372,11 +2374,11 @@ getTextIndexAtCursor(callback: AsyncCallback&lt;number&gt;): void ...@@ -2372,11 +2374,11 @@ getTextIndexAtCursor(callback: AsyncCallback&lt;number&gt;): void
```js ```js
inputClient.getTextIndexAtCursor((err, index) => { inputClient.getTextIndexAtCursor((err, index) => {
if (err !== undefined) { if (err) {
console.error('Failed to getTextIndexAtCursor: ${err.message}'); console.error('Failed to getTextIndexAtCursor: ${err.message}');
return; return;
} }
console.info('Succeeded in getTextIndexAtCursor: ' + index); console.info('Succeeded in getTextIndexAtCursor: ' + index);
}); });
``` ```
...@@ -2407,9 +2409,9 @@ getTextIndexAtCursor(): Promise&lt;number&gt; ...@@ -2407,9 +2409,9 @@ getTextIndexAtCursor(): Promise&lt;number&gt;
```js ```js
inputClient.getTextIndexAtCursor().then((index) => { inputClient.getTextIndexAtCursor().then((index) => {
console.info('Succeeded in getTextIndexAtCursor: ' + index); console.info('Succeeded in getTextIndexAtCursor: ' + index);
}).catch((err) => { }).catch((err) => {
console.error('Failed to getTextIndexAtCursor: ${err.message}'); console.error('Failed to getTextIndexAtCursor: ${err.message}');
}); });
``` ```
...@@ -2443,15 +2445,15 @@ sendExtendAction(action: ExtendAction, callback: AsyncCallback&lt;void&gt;): voi ...@@ -2443,15 +2445,15 @@ sendExtendAction(action: ExtendAction, callback: AsyncCallback&lt;void&gt;): voi
```js ```js
try { try {
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err) => { inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`); console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
return; return;
} }
console.info('Succeeded in sending extend action.'); console.info('Succeeded in sending extend action.');
}); });
} catch(error) { } catch(error) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(error)}`); console.error(`Failed to sendExtendAction: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -2490,13 +2492,13 @@ sendExtendAction(action: ExtendAction): Promise&lt;void&gt; ...@@ -2490,13 +2492,13 @@ sendExtendAction(action: ExtendAction): Promise&lt;void&gt;
```js ```js
try { try {
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY).then(() => { inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY).then(() => {
console.info('Succeeded in sending extend action.'); console.info('Succeeded in sending extend action.');
}).catch((err) => { }).catch((err) => {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`); console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
}); });
} catch(error) { } catch(error) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(error)}`); console.error(`Failed to sendExtendAction: ${JSON.stringify(error)}`);
} }
``` ```
...@@ -2587,11 +2589,11 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -2587,11 +2589,11 @@ 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) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in getting forward, text: ' + text); console.log('Succeeded in getting forward, text: ' + text);
}); });
``` ```
...@@ -2624,9 +2626,9 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -2624,9 +2626,9 @@ 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('Succeeded in getting forward, text: ' + text); console.info('Succeeded in getting forward, text: ' + text);
}).catch((err) => { }).catch((err) => {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2654,11 +2656,11 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -2654,11 +2656,11 @@ 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) {
console.error('Failed to getBackward: ' + JSON.stringify(err)); console.error('Failed to getBackward: ' + JSON.stringify(err));
return; return;
} }
console.log('Succeeded in getting borward, text: ' + text); console.log('Succeeded in getting borward, text: ' + text);
}); });
``` ```
...@@ -2691,9 +2693,9 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -2691,9 +2693,9 @@ 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('Succeeded in getting backward: ' + JSON.stringify(text)); console.info('Succeeded in getting backward: ' + JSON.stringify(text));
}).catch((err) => { }).catch((err) => {
console.error('Failed to getBackward: ' + JSON.stringify(err)); console.error('Failed to getBackward: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2721,15 +2723,15 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2721,15 +2723,15 @@ 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) {
console.error('Failed to deleteForward: ' + JSON.stringify(err)); console.error('Failed to deleteForward: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in deleting forward. '); console.info('Succeeded in deleting forward. ');
} else { } else {
console.error('Failed to deleteForward. '); console.error('Failed to deleteForward. ');
} }
}); });
``` ```
...@@ -2762,13 +2764,13 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -2762,13 +2764,13 @@ 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('Succeeded 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: ' + JSON.stringify(err)); console.error('Failed to delete forward: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2784,27 +2786,27 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2784,27 +2786,27 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------- | | -------- | ---------------------------- | ---- | -------------- |
| length | number | 是 | 文本长度。 | | length | number | 是 | 文本长度。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。| | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。|
**示例:** **示例:**
```js ```js
let length = 1; let length = 1;
textInputClient.deleteBackward(length, (err, result) => { textInputClient.deleteBackward(length, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to delete backward: ' + JSON.stringify(err)); console.error('Failed to delete backward: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in deleting backward. '); console.info('Succeeded in deleting backward. ');
} else { } else {
console.error('Failed to deleteBackward. '); console.error('Failed to deleteBackward. ');
} }
}); });
``` ```
...@@ -2837,13 +2839,13 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -2837,13 +2839,13 @@ 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('Succeeded in deleting backward. '); console.info('Succeeded in deleting backward. ');
} else { } else {
console.error('Failed to deleteBackward. '); console.error('Failed to deleteBackward. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to deleteBackward: ' + JSON.stringify(err)); console.error('Failed to deleteBackward: ' + JSON.stringify(err));
}); });
``` ```
### sendKeyFunction<sup>(deprecated)</sup> ### sendKeyFunction<sup>(deprecated)</sup>
...@@ -2858,27 +2860,27 @@ sendKeyFunction(action: number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2858,27 +2860,27 @@ sendKeyFunction(action: number, callback: AsyncCallback&lt;boolean&gt;): void
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 | | action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**示例:** **示例:**
```js ```js
let action = 1; let action = 1;
textInputClient.sendKeyFunction(action, (err, result) => { textInputClient.sendKeyFunction(action, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err)); console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in sending key function. '); console.info('Succeeded in sending key function. ');
} else { } else {
console.error('Failed to sendKeyFunction. '); console.error('Failed to sendKeyFunction. ');
} }
}); });
``` ```
...@@ -2911,13 +2913,13 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt; ...@@ -2911,13 +2913,13 @@ 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('Succeeded in sending key function. '); 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('Failed to sendKeyFunction:' + JSON.stringify(err)); console.error('Failed to sendKeyFunction:' + JSON.stringify(err));
}); });
``` ```
...@@ -2944,15 +2946,15 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2944,15 +2946,15 @@ 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) {
console.error('Failed to insertText: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Succeeded in inserting text. '); console.info('Succeeded in inserting text. ');
} else { } else {
console.error('Failed to insertText. '); console.error('Failed to insertText. ');
} }
}); });
``` ```
...@@ -2984,13 +2986,13 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -2984,13 +2986,13 @@ 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('Succeeded in inserting text. '); console.info('Succeeded in inserting text. ');
} else { } else {
console.error('Failed to insertText. '); console.error('Failed to insertText. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to insertText: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3016,12 +3018,12 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -3016,12 +3018,12 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
```js ```js
textInputClient.getEditorAttribute((err, editorAttribute) => { textInputClient.getEditorAttribute((err, editorAttribute) => {
if (err !== undefined) { if (err) {
console.error('Failed to getEditorAttribute: ' + 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));
console.log('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType)); console.log('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
}); });
``` ```
...@@ -3047,10 +3049,10 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -3047,10 +3049,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('Failed to getEditorAttribute: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
}); });
``` ```
<!--no_check--> <!--no_check-->
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册