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