提交 c564b9a7 编写于 作者: H Hollokin

【输入法框架】inputmethod.md及inputmethodengine.md部分示例代码修改及对多余接口说明进行删除

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 436fd08f
...@@ -126,7 +126,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea ...@@ -126,7 +126,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea
```js ```js
try{ try{
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'}, (err, result) => { inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard', extra: {}}, (err, result) => {
if (err) { if (err) {
console.error('switchInputMethod err: ' + JSON.stringify(err)); console.error('switchInputMethod err: ' + JSON.stringify(err));
return; return;
...@@ -175,7 +175,7 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt; ...@@ -175,7 +175,7 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
```js ```js
try { try {
inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard'}).then((result) => { inputMethod.switchInputMethod({packageName:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard', extra: {}}).then((result) => {
if (result) { if (result) {
console.info('Success to switchInputMethod.'); console.info('Success to switchInputMethod.');
} else { } else {
...@@ -240,7 +240,14 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb ...@@ -240,7 +240,14 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
```js ```js
let inputMethodSubtype = { let inputMethodSubtype = {
id: "com.example.kikainput", id: "com.example.kikainput",
label: "ServiceExtAbility" label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
} }
try { try {
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubtype, (err, result) => { inputMethod.switchCurrentInputMethodSubtype(inputMethodSubtype, (err, result) => {
...@@ -295,7 +302,14 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean& ...@@ -295,7 +302,14 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
```js ```js
let inputMethodSubtype = { let inputMethodSubtype = {
id: "com.example.kikainput", id: "com.example.kikainput",
label: "ServiceExtAbility" label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
} }
try { try {
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubtype).then((result) => { inputMethod.switchCurrentInputMethodSubtype(inputMethodSubtype).then((result) => {
...@@ -363,12 +377,20 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ...@@ -363,12 +377,20 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
```js ```js
let inputMethodProperty = { let inputMethodProperty = {
packageName:"com.example.kikakeyboard", packageName: "com.example.kikakeyboard",
methodId:"ServiceExtAbility" methodId: "ServiceExtAbility",
extra: {}
} }
let inputMethodSubProperty = { let inputMethodSubProperty = {
id: "com.example.kikainput", id: "com.example.kikainput",
label: "ServiceExtAbility" label: "ServiceExtAbility",
name: "",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
} }
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,result) => { inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,result) => {
...@@ -873,7 +895,8 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async ...@@ -873,7 +895,8 @@ 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',
extra:{}
} }
try { try {
InputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => { InputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => {
...@@ -923,6 +946,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr ...@@ -923,6 +946,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr
let inputMethodProperty = { let inputMethodProperty = {
packageName:'com.example.kikakeyboard', packageName:'com.example.kikakeyboard',
methodId:'com.example.kikakeyboard', methodId:'com.example.kikakeyboard',
extra:{}
} }
try { try {
InputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { InputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => {
......
# 输入法服务 # 输入法服务
本模块的作用是拉通普通应用和输入法应用,功能包括:普通应用通过输入法应用进行文本输入、普通应用与输入法服务绑定、普通应用对输入法应用进行显示请求和隐藏请求、普通应用对输入法应用当前状态进行监听等等。 本模块的作用是拉通输入法应用和其他三方应用(联系人、微信等),功能包括:将三方应用与输入法应用的服务进行绑定、三方应用通过输入法应用进行文本输入、三方应用对输入法应用进行显示键盘请求和隐藏键盘请求、三方应用对输入法应用当前状态进行监听等。
> **说明:** > **说明:**
> >
...@@ -69,7 +69,7 @@ getInputMethodAbility(): InputMethodAbility ...@@ -69,7 +69,7 @@ getInputMethodAbility(): InputMethodAbility
**示例:** **示例:**
```js ```js
let InputMethodAbility = inputMethodAbility.getInputMethodAbility(); let InputMethodAbility = inputMethodEngine.getInputMethodAbility();
``` ```
## inputMethodEngine.getKeyboardDelegate<sup>9+</sup> ## inputMethodEngine.getKeyboardDelegate<sup>9+</sup>
...@@ -89,7 +89,7 @@ getKeyboardDelegate(): KeyboardDelegate ...@@ -89,7 +89,7 @@ getKeyboardDelegate(): KeyboardDelegate
**示例:** **示例:**
```js ```js
let KeyboardDelegate = inputMethodAbility.getKeyboardDelegate(); let KeyboardDelegate = inputMethodEngine.getKeyboardDelegate();
``` ```
## inputMethodEngine.getInputMethodEngine<sup>(deprecated)</sup> ## inputMethodEngine.getInputMethodEngine<sup>(deprecated)</sup>
...@@ -183,8 +183,6 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC ...@@ -183,8 +183,6 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStart’时表示订阅输入法绑定。 | | type | string | 是 | 设置监听类型。<br/>-type为‘inputStart’时表示订阅输入法绑定。 |
| callback | [KeyboardController](#keyboardcontroller), [TextInputClient](#textinputclient) | 否 | 回调函数,返回取消订阅的KeyboardController和TextInputClient实例。 | | callback | [KeyboardController](#keyboardcontroller), [TextInputClient](#textinputclient) | 否 | 回调函数,返回取消订阅的KeyboardController和TextInputClient实例。 |
**示例:** **示例:**
```js ```js
...@@ -193,98 +191,6 @@ inputMethodEngine.getInputMethodEngine().off('inputStart', (kbController, textIn ...@@ -193,98 +191,6 @@ inputMethodEngine.getInputMethodEngine().off('inputStart', (kbController, textIn
}); });
``` ```
### on('inputStop')<sup>9+</sup>
on(type: 'inputStop', callback: () => void): void
订阅停止输入法应用事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStop’时表示订阅停止输入法应用事件。 |
| callback | void | 是 | 回调函数。 |
**示例:**
```js
inputMethodEngine.getInputMethodEngine().on('inputStop', () => {
console.log('inputMethodEngine inputStop');
});
```
### off('inputStop')<sup>9+</sup>
off(type: 'inputStop', callback: () => void): void
取消订阅停止输入法应用事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘inputStop’时表示订阅停止输入法应用事件。 |
| callback | void | 是 | 回调函数。 |
**示例:**
```js
inputMethodEngine.getInputMethodEngine().off('inputStop', () => {
console.log('inputMethodEngine delete inputStop notification.');
});
```
### on('setCallingWindow')<sup>9+</sup>
on(type: 'setCallingWindow', callback: (wid:number) => void): void
订阅设置调用窗口事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| callback | number | 是 | 回调函数,返回调用方window id。 |
**示例:**
```js
inputMethodEngine.getInputMethodEngine().on('setCallingWindow', (wid) => {
console.log('inputMethodEngine setCallingWindow');
});
```
### off('setCallingWindow')<sup>9+</sup>
off(type: 'setCallingWindow', callback: (wid:number) => void): void
取消订阅设置调用窗口事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| callback | number | 是 | 回调函数,返回调用方window id。 |
**示例:**
```js
inputMethodEngine.getInputMethodEngine().off('setCallingWindow', () => {
console.log('inputMethodEngine delete setCallingWindow notification.');
});
```
### on('keyboardShow'|'keyboardHide') ### on('keyboardShow'|'keyboardHide')
on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
...@@ -849,13 +755,11 @@ hide(): Promise&lt;void&gt; ...@@ -849,13 +755,11 @@ hide(): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { KeyboardController.hide().then(() => {
await KeyboardController.hide().then(() => { console.info('hide success.');
console.info('hide success.'); }).catch((err) => {
}).catch((err) => { console.info('hide err: ' + JSON.stringify(err));
console.info('hide err: ' + JSON.stringify(err)); });
});
}
``` ```
### hideKeyboard<sup>(deprecated)</sup> ### hideKeyboard<sup>(deprecated)</sup>
...@@ -909,13 +813,11 @@ hideKeyboard(): Promise&lt;void&gt; ...@@ -909,13 +813,11 @@ hideKeyboard(): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { KeyboardController.hideKeyboard().then(() => {
await KeyboardController.hideKeyboard().then(() => { console.info('hideKeyboard success.');
console.info('hideKeyboard success.'); }).catch((err) => {
}).catch((err) => { console.info('hideKeyboard err: ' + JSON.stringify(err));
console.info('hideKeyboard err: ' + JSON.stringify(err)); });
});
}
``` ```
## InputClient<sup>9+</sup> ## InputClient<sup>9+</sup>
...@@ -951,7 +853,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -951,7 +853,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
try { try {
InputClient.sendKeyFunction(keyFunction, (err, result) => { InputClient.sendKeyFunction(keyFunction, (err, result) => {
if (err) { if (err) {
console.error('sendKeyFunction err: ' + JSON.stringify(err)JSON.stringify(err)); console.error('sendKeyFunction err: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
...@@ -1084,17 +986,15 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -1084,17 +986,15 @@ getForward(length:number): Promise&lt;string&gt;
**示例:** **示例:**
```js ```js
async function InputMethodAbility() { let length = 1;
let length = 1; try {
try { InputClient.getForward(length).then((text) => {
await InputClient.getForward(length).then((text) => { console.info('getForward resul: ' + text);
console.info('getForward resul: ' + text); }).catch((err) => {
}).catch((err) => {
console.error('getForward err: ' + JSON.stringify(err));
});
} catch (err) {
console.error('getForward err: ' + JSON.stringify(err)); console.error('getForward err: ' + JSON.stringify(err));
} });
} catch (err) {
console.error('getForward err: ' + JSON.stringify(err));
} }
``` ```
...@@ -1171,17 +1071,15 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -1171,17 +1071,15 @@ getBackward(length:number): Promise&lt;string&gt;
**示例:** **示例:**
```js ```js
async function InputMethodAbility() { let length = 1;
let length = 1; try {
try { InputClient.getBackward(length).then((text) => {
await InputClient.getBackward(length).then((text) => { console.info('getBackward result: ' + text);
console.info('getBackward result: ' + text); }).catch((err) => {
}).catch((err) => {
console.error('getBackward err: ' + JSON.stringify(err));
});
} catch (err) {
console.error('getBackward err: ' + JSON.stringify(err)); console.error('getBackward err: ' + JSON.stringify(err));
} });
} catch (err) {
console.error('getBackward err: ' + JSON.stringify(err));
} }
``` ```
...@@ -1262,21 +1160,19 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -1262,21 +1160,19 @@ deleteForward(length:number): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodAbility() { let length = 1;
let length = 1; try {
try { InputClient.deleteForward(length).then((result) => {
await InputClient.deleteForward(length).then((result) => { if (result) {
if (result) { console.info('Success to deleteForward. ');
console.info('Success to deleteForward. '); } else {
} else { console.error('Failed to deleteForward. ');
console.error('Failed to deleteForward. '); }
} }).catch((err) => {
}).catch((err) => {
console.error('deleteForward err: ' + JSON.stringify(err));
});
} catch (err) {
console.error('deleteForward err: ' + JSON.stringify(err)); console.error('deleteForward err: ' + JSON.stringify(err));
} });
} catch (err) {
console.error('deleteForward err: ' + JSON.stringify(err));
} }
``` ```
...@@ -1357,18 +1253,16 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -1357,18 +1253,16 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodAbility() { let length = 1;
let length = 1; InputClient.deleteBackward(length).then((result) => {
await InputClient.deleteBackward(length).then((result) => { if (result) {
if (result) { console.info('Success to deleteBackward. ');
console.info('Success to deleteBackward. '); } else {
} else { console.error('Failed to deleteBackward. ');
console.error('Failed to deleteBackward. '); }
} }).catch((err) => {
}).catch((err) => { console.error('deleteBackward err: ' + JSON.stringify(err));
console.error('deleteBackward err: ' + JSON.stringify(err)); });
});
}
``` ```
### insertText<sup>9+</sup> ### insertText<sup>9+</sup>
...@@ -1443,20 +1337,18 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -1443,20 +1337,18 @@ insertText(text:string): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodAbility() { try {
try { InputClient.insertText('test').then((result) => {
await InputClient.insertText('test').then((result) => { if (result) {
if (result) { console.info('Success to insertText. ');
console.info('Success to insertText. '); } else {
} else { console.error('Failed to insertText. ');
console.error('Failed to insertText. '); }
} }).catch((err) => {
}).catch((err) => {
console.error('insertText err: ' + JSON.stringify(err));
});
} catch (e) {
console.error('insertText err: ' + JSON.stringify(err)); console.error('insertText err: ' + JSON.stringify(err));
} });
} catch (err) {
console.error('insertText err: ' + JSON.stringify(err));
} }
``` ```
...@@ -1520,14 +1412,12 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -1520,14 +1412,12 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { InputClient.getEditorAttribute().then((editorAttribute) => {
await InputClient.getEditorAttribute().then((editorAttribute) => { console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern)); console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType)); }).catch((err) => {
}).catch((err) => { console.error('getEditorAttribute err: ' + JSON.stringify(err));
console.error('getEditorAttribute err: ' + JSON.stringify(err)); });
});
}
``` ```
### moveCursor<sup>9+</sup> ### moveCursor<sup>9+</sup>
...@@ -1557,7 +1447,7 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1557,7 +1447,7 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
InputClient.moveCursor(inputMethodAbility.CURSOR_xxx, (err) => { InputClient.moveCursor(inputMethodEngine.CURSOR_xxx, (err) => {
if (err) { if (err) {
console.error('moveCursor err: ' + JSON.stringify(err)); console.error('moveCursor err: ' + JSON.stringify(err));
return; return;
...@@ -1600,20 +1490,14 @@ moveCursor(direction: number): Promise&lt;void&gt; ...@@ -1600,20 +1490,14 @@ moveCursor(direction: number): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
async function InputMethodAbility() { try {
try { InputClient.moveCursor(inputMethodEngine.CURSOR_UP).then(() => {
await InputClient.moveCursor(inputMethodEngine.CURSOR_xxx).then((err) => { console.log('moveCursor success');
if (err) { }).catch((err) => {
console.log('moveCursor err: ' + JSON.stringify(err)); console.error('moveCursor success err: ' + JSON.stringify(err));
return; });
} } catch (err) {
console.log('moveCursor success'); console.log('moveCursor err: ' + JSON.stringify(err));
}).catch((err) => {
console.error('moveCursor success err: ' + JSON.stringify(err));
});
} catch (err) {
console.log('moveCursor err: ' + JSON.stringify(err));
}
} }
``` ```
...@@ -1706,14 +1590,12 @@ getForward(length:number): Promise&lt;string&gt; ...@@ -1706,14 +1590,12 @@ getForward(length:number): Promise&lt;string&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { let length = 1;
let length = 1; TextInputClient.getForward(length).then((text) => {
await TextInputClient.getForward(length).then((text) => { console.info('getForward result: ' + JSON.stringify(text));
console.info('getForward result---res: ' + text); }).catch((err) => {
}).catch((err) => { console.error('getForward err: ' + JSON.stringify(err));
console.error('getForward err: ' + JSON.stringify(err)); });
});
}
``` ```
### getBackward<sup>(deprecated)</sup> ### getBackward<sup>(deprecated)</sup>
...@@ -1775,14 +1657,12 @@ getBackward(length:number): Promise&lt;string&gt; ...@@ -1775,14 +1657,12 @@ getBackward(length:number): Promise&lt;string&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { let length = 1;
let length = 1; TextInputClient.getBackward(length).then((text) => {
await TextInputClient.getBackward(length).then((text) => { console.info('getBackward result: ' + JSON.stringify(text));
console.info('getBackward result---res: ' + text); }).catch((err) => {
}).catch((err) => { console.error('getBackward err: ' + JSON.stringify(err));
console.error('getBackward err: ' + JSON.stringify(err)); });
});
}
``` ```
### deleteForward<sup>(deprecated)</sup> ### deleteForward<sup>(deprecated)</sup>
...@@ -1848,18 +1728,16 @@ deleteForward(length:number): Promise&lt;boolean&gt; ...@@ -1848,18 +1728,16 @@ deleteForward(length:number): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { let length = 1;
let length = 1; TextInputClient.deleteForward(length).then((result) => {
await TextInputClient.deleteForward(length).then((result) => { if (result) {
if (result) { console.info('Succeed in deleting forward. ');
console.info('Success to deleteForward. '); } else {
} else { console.error('Failed to delete forward. ');
console.error('Failed to deleteForward. '); }
} }).catch((err) => {
}).catch((err) => { console.error('Failed to delete forward err: ' + JSON.stringify(err));
console.error('deleteForward err: ' + JSON.stringify(err)); });
});
}
``` ```
### deleteBackward<sup>(deprecated)</sup> ### deleteBackward<sup>(deprecated)</sup>
...@@ -1925,18 +1803,16 @@ deleteBackward(length:number): Promise&lt;boolean&gt; ...@@ -1925,18 +1803,16 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { let length = 1;
let length = 1; TextInputClient.deleteBackward(length).then((result) => {
await TextInputClient.deleteBackward(length).then((result) => { if (result) {
if (result) { console.info('Success to deleteBackward. ');
console.info('Success to deleteBackward. '); } else {
} else { console.error('Failed to deleteBackward. ');
console.error('Failed to deleteBackward. '); }
} }).catch((err) => {
}).catch((err) => { console.error('deleteBackward err: ' + JSON.stringify(err));
console.error('deleteBackward err: ' + JSON.stringify(err)); });
});
}
``` ```
### sendKeyFunction<sup>(deprecated)</sup> ### sendKeyFunction<sup>(deprecated)</sup>
...@@ -2000,17 +1876,15 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt; ...@@ -2000,17 +1876,15 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { TextInputClient.sendKeyFunction(keyFunction).then((result) => {
await client.sendKeyFunction(keyFunction).then((result) => { if (result) {
if (result) { console.info('Success to sendKeyFunction. ');
console.info('Success to sendKeyFunction. '); } 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)); });
});
}
``` ```
### insertText<sup>(deprecated)</sup> ### insertText<sup>(deprecated)</sup>
...@@ -2075,17 +1949,15 @@ insertText(text:string): Promise&lt;boolean&gt; ...@@ -2075,17 +1949,15 @@ insertText(text:string): Promise&lt;boolean&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { TextInputClient.insertText('test').then((result) => {
await TextInputClient.insertText('test').then((result) => { if (result) {
if (result) { console.info('Success to insertText. ');
console.info('Success to insertText. '); } else {
} else { console.error('Failed to insertText. ');
console.error('Failed to insertText. '); }
} }).catch((err) => {
}).catch((err) => { console.error('insertText err: ' + JSON.stringify(err));
console.error('insertText err: ' + JSON.stringify(err)); });
});
}
``` ```
### getEditorAttribute<sup>(deprecated)</sup> ### getEditorAttribute<sup>(deprecated)</sup>
...@@ -2140,12 +2012,10 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt; ...@@ -2140,12 +2012,10 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
**示例:** **示例:**
```js ```js
async function InputMethodEngine() { TextInputClient.getEditorAttribute().then((editorAttribute) => {
await TextInputClient.getEditorAttribute().then((editorAttribute) => { console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern)); console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType)); }).catch((err) => {
}).catch((err) => { console.error('getEditorAttribute err: ' + JSON.stringify(err));
console.error('getEditorAttribute err: ' + JSON.stringify(err)); });
});
}
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册