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

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

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 2e52d650
......@@ -38,9 +38,9 @@ Extension生命周期回调,在拉起Extension输入法应用时调用,执
```js
class InputMethodExt extends InputMethodExtensionAbility {
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
}
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
}
}
```
......@@ -56,8 +56,8 @@ Extension生命周期回调,在销毁输入法应用时回调,执行资源
```js
class InputMethodExt extends InputMethodExtensionAbility {
onDestroy() {
console.log('onDestroy');
}
onDestroy() {
console.log('onDestroy');
}
}
```
......@@ -21,9 +21,9 @@ import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext';
```js
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
class EntryAbility extends InputMethodExtensionAbility {
onCreate() {
let context = this.context;
}
onCreate() {
let context = this.context;
}
}
```
......@@ -45,7 +45,7 @@ destroy(callback: AsyncCallback\<void>): void
```js
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>;
```js
this.context.destroy().then(() => {
console.log('Succeed in destoring context.');
console.log('Succeed in destoring context.');
}).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
```js
let im = inputMethod.getCurrentInputMethod();
let prop = {
packageName: im.packageName,
methodId: im.methodId,
name: im.packageName,
id: im.methodId,
extra: {}
packageName: im.packageName,
methodId: im.methodId,
name: im.packageName,
id: im.methodId,
extra: {}
}
try{
inputMethod.switchInputMethod(prop, (err, result) => {
if (err !== undefined) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in switching inputmethod.');
} else {
console.error('Failed to switchInputMethod.');
}
});
inputMethod.switchInputMethod(prop, (err, result) => {
if (err) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in switching inputmethod.');
} else {
console.error('Failed to switchInputMethod.');
}
});
} catch(err) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
}
```
## inputMethod.switchInputMethod<sup>9+</sup>
......@@ -185,24 +185,24 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
```js
let im = inputMethod.getCurrentInputMethod();
let prop = {
packageName: im.packageName,
methodId: im.methodId,
name: im.packageName,
id: im.methodId,
extra: {}
packageName: im.packageName,
methodId: im.methodId,
name: im.packageName,
id: im.methodId,
extra: {}
}
try {
inputMethod.switchInputMethod(prop).then((result) => {
if (result) {
console.info('Succeeded in switching inputmethod.');
} else {
console.error('Failed to switchInputMethod.');
}
}).catch((err) => {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
})
} catch(err) {
inputMethod.switchInputMethod(prop).then((result) => {
if (result) {
console.info('Succeeded in switching inputmethod.');
} else {
console.error('Failed to switchInputMethod.');
}
}).catch((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
```js
try {
inputMethod.switchCurrentInputMethodSubtype({
id: "ServiceExtAbility",
label: "",
name: "com.example.kikakeyboard",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}, (err, result) => {
if (err !== undefined) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in switching currentInputMethodSubtype.');
} else {
console.error('Failed to switchCurrentInputMethodSubtype');
}
});
inputMethod.switchCurrentInputMethodSubtype({
id: "ServiceExtAbility",
label: "",
name: "com.example.kikakeyboard",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}, (err, result) => {
if (err) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in switching currentInputMethodSubtype.');
} else {
console.error('Failed to switchCurrentInputMethodSubtype');
}
});
} 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&
```js
try {
inputMethod.switchCurrentInputMethodSubtype({
id: "ServiceExtAbility",
label: "",
name: "com.example.kikakeyboard",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}).then((result) => {
if (result) {
console.info('Succeeded in switching currentInputMethodSubtype.');
} else {
console.error('Failed to switchCurrentInputMethodSubtype.');
}
}).catch((err) => {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
inputMethod.switchCurrentInputMethodSubtype({
id: "ServiceExtAbility",
label: "",
name: "com.example.kikakeyboard",
mode: "upper",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
}).then((result) => {
if (result) {
console.info('Succeeded in switching currentInputMethodSubtype.');
} else {
console.error('Failed to switchCurrentInputMethodSubtype.');
}
}).catch((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
let im = inputMethod.getCurrentInputMethod();
let imSubType = inputMethod.getCurrentInputMethodSubtype();
try {
inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => {
if (err !== undefined) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else {
console.error('Failed to switchCurrentInputMethodAndSubtype.');
}
});
inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => {
if (err) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else {
console.error('Failed to switchCurrentInputMethodAndSubtype.');
}
});
} 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
let im = inputMethod.getCurrentInputMethod();
let imSubType = inputMethod.getCurrentInputMethodSubtype();
try {
inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType).then((result) => {
if (result) {
console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else {
console.error('Failed to switchCurrentInputMethodAndSubtype.');
}
}).catch((err) => {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
})
} catch(err) {
inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType).then((result) => {
if (result) {
console.info('Succeeded in switching currentInputMethodAndSubtype.');
} else {
console.error('Failed to switchCurrentInputMethodAndSubtype.');
}
}).catch((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
```js
try {
let textConfig: inputMethod.TextConfig = {
inputAttribute: {
textInputType: 0,
enterKeyType: 1
}
};
inputMethodController.attach(true, textConfig, (err) => {
if (err !== undefined) {
console.error(`Failed to attach: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in attaching the inputMethod.');
});
let textConfig: inputMethod.TextConfig = {
inputAttribute: {
textInputType: 0,
enterKeyType: 1
}
};
inputMethodController.attach(true, textConfig, (err) => {
if (err) {
console.error(`Failed to attach: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in attaching the inputMethod.');
});
} 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;
```js
try {
let textConfig: inputMethod.TextConfig = {
inputAttribute: {
textInputType: 0,
enterKeyType: 1
}
};
inputMethodController.attach(true, textConfig).then(() => {
console.info('Succeeded in attaching inputMethod.');
}).catch((err) => {
console.error(`Failed to attach: ${JSON.stringify(err)}`);
})
let textConfig: inputMethod.TextConfig = {
inputAttribute: {
textInputType: 0,
enterKeyType: 1
}
};
inputMethodController.attach(true, textConfig).then(() => {
console.info('Succeeded in attaching inputMethod.');
}).catch((err) => {
console.error(`Failed to attach: ${JSON.stringify(err)}`);
})
} 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
```js
inputMethodController.showTextInput((err) => {
if (err !== undefined) {
console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in showing the inputMethod.');
if (err) {
console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in showing the inputMethod.');
});
```
......@@ -821,9 +821,9 @@ showTextInput(): Promise&lt;void&gt;
```js
inputMethodController.showTextInput().then(() => {
console.info('Succeeded in showing text input.');
console.info('Succeeded in showing text input.');
}).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
```js
inputMethodController.hideTextInput((err) => {
if (err !== undefined) {
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in hiding text input.');
if (err) {
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in hiding text input.');
});
```
......@@ -932,11 +932,11 @@ detach(callback: AsyncCallback&lt;void&gt;): void
```js
inputMethodController.detach((err) => {
if (err !== undefined) {
console.error(`Failed to detach: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in detaching inputMethod.');
if (err) {
console.error(`Failed to detach: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in detaching inputMethod.');
});
```
......@@ -967,9 +967,9 @@ detach(): Promise&lt;void&gt;
```js
inputMethodController.detach().then(() => {
console.info('Succeeded in detaching inputMethod.');
console.info('Succeeded in detaching inputMethod.');
}).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
```js
try {
let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId, (err) => {
if (err !== undefined) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in setting callingWindow.');
});
let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId, (err) => {
if (err) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in setting callingWindow.');
});
} 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;
```js
try {
let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId).then(() => {
console.info('Succeeded in setting callingWindow.');
}).catch((err) => {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
})
let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId).then(() => {
console.info('Succeeded in setting callingWindow.');
}).catch((err) => {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
})
} 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
```js
try {
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}, (err) => {
if (err !== undefined) {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in updating cursorInfo.');
});
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}, (err) => {
if (err) {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in updating cursorInfo.');
});
} 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;
```js
try {
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}).then(() => {
console.info('Succeeded in updating cursorInfo.');
}).catch((err) => {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
})
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}).then(() => {
console.info('Succeeded in updating cursorInfo.');
}).catch((err) => {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
})
} 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
```js
try {
inputMethodController.changeSelection('text', 0, 5, (err) => {
if (err !== undefined) {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in changing selection.');
});
inputMethodController.changeSelection('text', 0, 5, (err) => {
if (err) {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in changing selection.');
});
} 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;
```js
try {
inputMethodController.changeSelection('test', 0, 5).then(() => {
console.info('Succeeded in changing selection.');
}).catch((err) => {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
})
inputMethodController.changeSelection('test', 0, 5).then(() => {
console.info('Succeeded in changing selection.');
}).catch((err) => {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
})
} 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;):
```js
try {
inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}, (err) => {
if (err !== undefined) {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in updating attribute.');
});
inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}, (err) => {
if (err) {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in updating attribute.');
});
} 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;
```js
try {
inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}).then(() => {
console.info('Succeeded in updating attribute.');
}).catch((err) => {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
})
inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}).then(() => {
console.info('Succeeded in updating attribute.');
}).catch((err) => {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
})
} 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
```js
try {
inputMethodController.stopInputSession((error, result) => {
if (error !== undefined) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error));
return;
}
if (result) {
console.info('Succeeded in stopping inputSession.');
} else {
console.error('Failed to stopInputSession.');
}
});
inputMethodController.stopInputSession((error, result) => {
if (error) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error));
return;
}
if (result) {
console.info('Succeeded in stopping inputSession.');
} else {
console.error('Failed to stopInputSession.');
}
});
} 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;
```js
try {
inputMethodController.stopInputSession().then((result) => {
if (result) {
console.info('Succeeded in stopping inputSession.');
} else {
console.error('Failed to stopInputSession.');
}
}).catch((err) => {
console.error('Failed to stopInputSession: ' + JSON.stringify(err));
})
} catch(err) {
inputMethodController.stopInputSession().then((result) => {
if (result) {
console.info('Succeeded in stopping inputSession.');
} else {
console.error('Failed to stopInputSession.');
}
}).catch((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
```js
inputMethodController.showSoftKeyboard((err) => {
if (err === undefined) {
console.info('Succeeded in showing softKeyboard.');
} else {
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
}
if (!err) {
console.info('Succeeded in showing softKeyboard.');
} else {
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
}
})
```
......@@ -1485,9 +1485,9 @@ showSoftKeyboard(): Promise&lt;void&gt;
```js
inputMethodController.showSoftKeyboard().then(() => {
console.log('Succeeded in showing softKeyboard.');
console.log('Succeeded in showing softKeyboard.');
}).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
```js
inputMethodController.hideSoftKeyboard((err) => {
if (err === undefined) {
console.info('Succeeded in hiding softKeyboard.');
} else {
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
}
if (!err) {
console.info('Succeeded in hiding softKeyboard.');
} else {
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
}
})
```
......@@ -1561,9 +1561,9 @@ hideSoftKeyboard(): Promise&lt;void&gt;
```js
inputMethodController.hideSoftKeyboard().then(() => {
console.log('Succeeded in hiding softKeyboard.');
console.log('Succeeded in hiding softKeyboard.');
}).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
```js
inputMethodController.stopInput((error, result) => {
if (error !== undefined) {
console.error('Failed to stopInput: ' + JSON.stringify(error));
return;
}
if (result) {
console.info('Succeeded in stopping input.');
} else {
console.error('Failed to stopInput.');
}
if (error) {
console.error('Failed to stopInput: ' + JSON.stringify(error));
return;
}
if (result) {
console.info('Succeeded in stopping input.');
} else {
console.error('Failed to stopInput.');
}
});
```
......@@ -1627,13 +1627,13 @@ stopInput(): Promise&lt;boolean&gt;
```js
inputMethodController.stopInput().then((result) => {
if (result) {
console.info('Succeeded in stopping input.');
} else {
console.error('Failed to stopInput.');
}
if (result) {
console.info('Succeeded in stopping input.');
} else {
console.error('Failed to stopInput.');
}
}).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;
```js
try {
inputMethodController.on('insertText', (text) => {
console.info(`Succeeded in subscribing insertText: ${text}`);
});
inputMethodController.on('insertText', (text) => {
console.info(`Succeeded in subscribing insertText: ${text}`);
});
} 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
```js
try {
inputMethodController.on('deleteLeft', (length) => {
console.info(`Succeeded in subscribing deleteLeft, length: ${length}`);
});
inputMethodController.on('deleteLeft', (length) => {
console.info(`Succeeded in subscribing deleteLeft, length: ${length}`);
});
} catch(error) {
console.error(`Failed to subscribe deleteLeft: ${JSON.stringify(error)}`);
console.error(`Failed to subscribe deleteLeft: ${JSON.stringify(error)}`);
}
try {
inputMethodController.on('deleteRight', (length) => {
console.info(`Succeeded in subscribing deleteRight, length: ${length}`);
});
inputMethodController.on('deleteRight', (length) => {
console.info(`Succeeded in subscribing deleteRight, length: ${length}`);
});
} 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
```js
try {
inputMethodController.on('sendKeyboardStatus', (keyBoardStatus) => {
console.info(`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus: ${keyBoardStatus}`);
});
inputMethodController.on('sendKeyboardStatus', (keyBoardStatus) => {
console.info(`Succeeded in subscribing sendKeyboardStatus, keyBoardStatus: ${keyBoardStatus}`);
});
} 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
```js
try {
inputMethodController.on('sendFunctionKey', (functionKey) => {
console.info(`Succeeded in subscribing sendFunctionKey, functionKey.enterKeyType: ${functionKey.enterKeyType}`);
});
inputMethodController.on('sendFunctionKey', (functionKey) => {
console.info(`Succeeded in subscribing sendFunctionKey, functionKey.enterKeyType: ${functionKey.enterKeyType}`);
});
} 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
```js
try {
inputMethodController.on('moveCursor', (direction) => {
console.info(`Succeeded in subscribing moveCursor, direction: ${direction}`);
});
inputMethodController.on('moveCursor', (direction) => {
console.info(`Succeeded in subscribing moveCursor, direction: ${direction}`);
});
} 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
```js
try {
inputMethodController.on('handleExtendAction', (action) => {
console.info(`Succeeded in subscribing handleExtendAction, action: ${action}`);
});
inputMethodController.on('handleExtendAction', (action) => {
console.info(`Succeeded in subscribing handleExtendAction, action: ${action}`);
});
} 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
```js
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
```js
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
```js
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
```js
let inputMethodProperty = {
packageName: 'com.example.kikakeyboard',
methodId: 'com.example.kikakeyboard',
name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard',
extra:{}
packageName: 'com.example.kikakeyboard',
methodId: 'com.example.kikakeyboard',
name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard',
extra:{}
}
try {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => {
if (err !== undefined) {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in listing inputMethodSubtype.');
});
inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => {
if (err) {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in listing inputMethodSubtype.');
});
} 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
```js
let inputMethodProperty = {
packageName: 'com.example.kikakeyboard',
methodId: 'com.example.kikakeyboard',
name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard',
extra:{}
packageName: 'com.example.kikakeyboard',
methodId: 'com.example.kikakeyboard',
name: 'com.example.kikakeyboard',
id: 'com.example.kikakeyboard',
extra:{}
}
try {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => {
console.info('Succeeded in listing inputMethodSubtype.');
}).catch((err) => {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => {
console.info('Succeeded in listing inputMethodSubtype.');
}).catch((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
```js
try {
inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err !== undefined) {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in listing currentInputMethodSubtype.');
});
inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err) {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in listing currentInputMethodSubtype.');
});
} 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;
```js
try {
inputMethodSetting.listCurrentInputMethodSubtype().then((data) => {
console.info('Succeeded in listing currentInputMethodSubtype.');
}).catch((err) => {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
})
} catch(err) {
inputMethodSetting.listCurrentInputMethodSubtype().then((data) => {
console.info('Succeeded in listing currentInputMethodSubtype.');
}).catch((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
```js
try {
inputMethodSetting.getInputMethods(true, (err,data) => {
if (err !== undefined) {
console.error('Failed to getInputMethods: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting inputMethods.');
});
inputMethodSetting.getInputMethods(true, (err,data) => {
if (err) {
console.error('Failed to getInputMethods: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting inputMethods.');
});
} 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
```js
try {
inputMethodSetting.getInputMethods(true).then((data) => {
console.info('Succeeded in getting inputMethods.');
}).catch((err) => {
console.error('Failed to getInputMethods: ' + JSON.stringify(err));
})
} catch(err) {
inputMethodSetting.getInputMethods(true).then((data) => {
console.info('Succeeded in getting inputMethods.');
}).catch((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
```js
try {
inputMethodSetting.showOptionalInputMethods((err, data) => {
if (err !== undefined) {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing optionalInputMethods.');
});
inputMethodSetting.showOptionalInputMethods((err, data) => {
if (err) {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing optionalInputMethods.');
});
} 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;
```js
inputMethodSetting.showOptionalInputMethods().then((data) => {
console.info('Succeeded in showing optionalInputMethods.');
console.info('Succeeded in showing optionalInputMethods.');
}).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;)
```js
inputMethodSetting.listInputMethod((err,data) => {
if (err !== undefined) {
console.error('Failed to listInputMethod: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in listing inputMethod.');
if (err) {
console.error('Failed to listInputMethod: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in listing inputMethod.');
});
```
......@@ -2488,9 +2488,9 @@ listInputMethod(): Promise&lt;Array&lt;InputMethodProperty&gt;&gt;
```js
inputMethodSetting.listInputMethod().then((data) => {
console.info('Succeeded in listing inputMethod.');
console.info('Succeeded in listing inputMethod.');
}).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
```js
inputMethodSetting.displayOptionalInputMethod((err) => {
if (err !== undefined) {
console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in displaying optionalInputMethod.');
if (err) {
console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in displaying optionalInputMethod.');
});
```
......@@ -2546,8 +2546,8 @@ displayOptionalInputMethod(): Promise&lt;void&gt;
```js
inputMethodSetting.displayOptionalInputMethod().then(() => {
console.info('Succeeded in displaying optionalInputMethod.');
console.info('Succeeded in displaying optionalInputMethod.');
}).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
```js
inputMethodEngine.getInputMethodEngine().on('inputStart', (kbController, textClient) => {
let keyboardController = kbController;
let textInputClient = textClient;
let keyboardController = kbController;
let textInputClient = textClient;
});
```
......@@ -189,7 +189,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
```js
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
```js
inputMethodEngine.getInputMethodEngine().on('keyboardShow', () => {
console.log('inputMethodEngine keyboardShow.');
console.log('inputMethodEngine keyboardShow.');
});
inputMethodEngine.getInputMethodEngine().on('keyboardHide', () => {
console.log('inputMethodEngine keyboardHide.');
console.log('inputMethodEngine keyboardHide.');
});
```
......@@ -264,8 +264,8 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient:
```js
inputMethodEngine.getInputMethodAbility().on('inputStart', (kbController, client) => {
let keyboardController = kbController;
let inputClient = client;
let keyboardController = kbController;
let inputClient = client;
});
```
......@@ -309,7 +309,7 @@ on(type: 'inputStop', callback: () => void): void
```js
inputMethodEngine.getInputMethodAbility().on('inputStop', () => {
console.log('inputMethodAbility inputStop');
console.log('inputMethodAbility inputStop');
});
```
......@@ -332,7 +332,7 @@ off(type: 'inputStop', callback: () => void): void
```js
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
```js
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
```js
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
```js
inputMethodEngine.getInputMethodAbility().on('keyboardShow', () => {
console.log('InputMethodAbility keyboardShow.');
console.log('InputMethodAbility keyboardShow.');
});
inputMethodEngine.getInputMethodAbility().on('keyboardHide', () => {
console.log('InputMethodAbility keyboardHide.');
console.log('InputMethodAbility keyboardHide.');
});
```
......@@ -427,10 +427,10 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
```js
inputMethodEngine.getInputMethodAbility().off('keyboardShow', () => {
console.log('InputMethodAbility delete keyboardShow notification.');
console.log('InputMethodAbility delete keyboardShow notification.');
});
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
```js
inputMethodEngine.getInputMethodAbility().on('setSubtype', (inputMethodSubtype) => {
console.log('InputMethodAbility setSubtype.');
console.log('InputMethodAbility setSubtype.');
});
```
......@@ -476,7 +476,7 @@ off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => v
```js
inputMethodEngine.getInputMethodAbility().off('setSubtype', () => {
console.log('InputMethodAbility delete setSubtype notification.');
console.log('InputMethodAbility delete setSubtype notification.');
});
```
......@@ -513,7 +513,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
}
try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) {
if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
return;
}
......@@ -590,7 +590,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
}
try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) {
if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
return;
}
......@@ -642,7 +642,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
}
try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) {
if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err));
return;
}
......@@ -687,14 +687,14 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
```js
inputMethodEngine.getKeyboardDelegate().on('keyUp', (keyEvent) => {
console.info('inputMethodEngine keyCode.(keyUp):' + JSON.stringify(keyEvent.keyCode));
console.info('inputMethodEngine keyAction.(keyUp):' + JSON.stringify(keyEvent.keyAction));
return true;
console.info('inputMethodEngine keyCode.(keyUp):' + JSON.stringify(keyEvent.keyCode));
console.info('inputMethodEngine keyAction.(keyUp):' + JSON.stringify(keyEvent.keyAction));
return true;
});
inputMethodEngine.getKeyboardDelegate().on('keyDown', (keyEvent) => {
console.info('inputMethodEngine keyCode.(keyDown):' + JSON.stringify(keyEvent.keyCode));
console.info('inputMethodEngine keyAction.(keyDown):' + JSON.stringify(keyEvent.keyAction));
return true;
console.info('inputMethodEngine keyCode.(keyDown):' + JSON.stringify(keyEvent.keyCode));
console.info('inputMethodEngine keyAction.(keyDown):' + JSON.stringify(keyEvent.keyAction));
return true;
});
```
......@@ -717,12 +717,12 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
```js
inputMethodEngine.getKeyboardDelegate().off('keyUp', (keyEvent) => {
console.log('delete keyUp notification.');
return true;
console.log('delete keyUp notification.');
return true;
});
inputMethodEngine.getKeyboardDelegate().off('keyDown', (keyEvent) => {
console.log('delete keyDown notification.');
return true;
console.log('delete keyDown notification.');
return true;
});
```
......@@ -745,9 +745,9 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
```js
inputMethodEngine.getKeyboardDelegate().on('cursorContextChange', (x, y, height) => {
console.log('inputMethodEngine cursorContextChange x:' + x);
console.log('inputMethodEngine cursorContextChange y:' + y);
console.log('inputMethodEngine cursorContextChange height:' + height);
console.log('inputMethodEngine cursorContextChange x:' + x);
console.log('inputMethodEngine cursorContextChange y:' + y);
console.log('inputMethodEngine cursorContextChange height:' + height);
});
```
......@@ -771,7 +771,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y: number, height: numbe
```js
inputMethodEngine.getKeyboardDelegate().off('cursorContextChange', (x, y, height) => {
console.log('delete cursorContextChange notification.');
console.log('delete cursorContextChange notification.');
});
```
### on('selectionChange')
......@@ -793,10 +793,10 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
```js
inputMethodEngine.getKeyboardDelegate().on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.log('inputMethodEngine beforeEach selectionChange oldBegin:' + oldBegin);
console.log('inputMethodEngine beforeEach selectionChange oldEnd:' + oldEnd);
console.log('inputMethodEngine beforeEach selectionChange newBegin:' + newBegin);
console.log('inputMethodEngine beforeEach selectionChange newEnd:' + newEnd);
console.log('inputMethodEngine beforeEach selectionChange oldBegin:' + oldBegin);
console.log('inputMethodEngine beforeEach selectionChange oldEnd:' + oldEnd);
console.log('inputMethodEngine beforeEach selectionChange newBegin:' + newBegin);
console.log('inputMethodEngine beforeEach selectionChange newEnd:' + newEnd);
});
```
......@@ -837,13 +837,13 @@ on(type: 'textChange', callback: (text: string) => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本变化事件。<br/>-&nbsp;type为’textChange‘时,表示订阅文本变化事件。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。|
**示例:**
```js
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
```js
inputMethodEngine.getKeyboardDelegate().off('textChange', (text) => {
console.log('delete textChange notification. text:' + text);
console.log('delete textChange notification. text:' + text);
});
```
......@@ -1017,6 +1017,7 @@ try {
resize(width: number, height: number, callback: AsyncCallback\<void>): void
改变当前面板大小,使用callback异步回调。
面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1088,6 +1089,7 @@ try {
moveTo(x: number, y: number, callback: AsyncCallback\<void>): void
移动面板位置,使用callback异步回调。
对FLG_FIXED状态的panel不产生实际移动效果。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1260,7 +1262,7 @@ promise.then(() => {
on(type: 'show' | 'hide', callback: () => void): void
监听当前面板状态,可监听面板类型为show或者hide, 使用callback异步回调。
监听当前面板状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1283,7 +1285,7 @@ panel.on('show', () => {
off(type: 'show' | 'hide', callback?: () => void): void
取消监听当前面板状态,可取消监听的面板类型为show或者hide,使用callback异步回调。
取消监听当前面板状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1351,11 +1353,11 @@ hide(callback: AsyncCallback&lt;void&gt;): void
```js
keyboardController.hide((err) => {
if (err !== undefined) {
console.error('Failed to hide keyboard: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in hiding keyboard.');
if (err) {
console.error('Failed to hide keyboard: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in hiding keyboard.');
});
```
......@@ -1385,9 +1387,9 @@ hide(): Promise&lt;void&gt;
```js
keyboardController.hide().then(() => {
console.info('Succeeded in hiding keyboard.');
console.info('Succeeded in hiding keyboard.');
}).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
```js
keyboardController.hideKeyboard((err) => {
if (err !== undefined) {
console.error('Failed to hide Keyboard: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in hiding keyboard.');
if (err) {
console.error('Failed to hide Keyboard: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in hiding keyboard.');
});
```
......@@ -1443,9 +1445,9 @@ hideKeyboard(): Promise&lt;void&gt;
```js
keyboardController.hideKeyboard().then(() => {
console.info('Succeeded in hiding keyboard.');
console.info('Succeeded in hiding keyboard.');
}).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
```js
let action = 1;
try {
inputClient.sendKeyFunction(action, (err, result) => {
if (err !== undefined) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in sending key function. ');
} else {
console.error('Failed to sendKeyFunction. ');
}
});
inputClient.sendKeyFunction(action, (err, result) => {
if (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in sending key function. ');
} else {
console.error('Failed to sendKeyFunction. ');
}
});
} 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;
```js
let action = 1;
try {
inputClient.sendKeyFunction(action).then((result) => {
if (result) {
console.info('Succeeded in sending key function. ');
} else {
console.error('Failed to sendKeyFunction. ');
}
}).catch((err) => {
console.error('Failed to sendKeyFunction:' + JSON.stringify(err));
});
inputClient.sendKeyFunction(action).then((result) => {
if (result) {
console.info('Succeeded in sending key function. ');
} else {
console.error('Failed to sendKeyFunction. ');
}
}).catch((err) => {
console.error('Failed to sendKeyFunction:' + JSON.stringify(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
```js
let length = 1;
try {
inputClient.getForward(length, (err, text) => {
if (err !== undefined) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting forward, text: ' + text);
});
inputClient.getForward(length, (err, text) => {
if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting forward, text: ' + text);
});
} 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;
```js
let length = 1;
try {
inputClient.getForward(length).then((text) => {
console.info('Succeeded in getting forward, text: ' + text);
}).catch((err) => {
console.error('Failed to getForward: ' + JSON.stringify(err));
});
} catch (err) {
inputClient.getForward(length).then((text) => {
console.info('Succeeded in getting forward, text: ' + text);
}).catch((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
```js
let length = 1;
try {
inputClient.getBackward(length, (err, text) => {
if (err !== undefined) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting backward, text: ' + text);
});
inputClient.getBackward(length, (err, text) => {
if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting backward, text: ' + text);
});
} 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;
```js
let length = 1;
try {
inputClient.getBackward(length).then((text) => {
console.info('Succeeded in getting backward, text: ' + text);
}).catch((err) => {
console.error('Failed to getForward: ' + JSON.stringify(err));
});
} catch (err) {
inputClient.getBackward(length).then((text) => {
console.info('Succeeded in getting backward, text: ' + text);
}).catch((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
```js
let length = 1;
try {
inputClient.deleteForward(length, (err, result) => {
if (err !== undefined) {
console.error('Failed to delete forward: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in deleting forward. ');
} else {
console.error('Failed to delete forward: ' + JSON.stringify(err));
}
});
inputClient.deleteForward(length, (err, result) => {
if (err) {
console.error('Failed to delete forward: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in deleting forward. ');
} else {
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));
}
```
......@@ -1840,17 +1842,17 @@ deleteForward(length:number): Promise&lt;boolean&gt;
```js
let length = 1;
try {
inputClient.deleteForward(length).then((result) => {
if (result) {
console.info('Succeeded in deleting forward. ');
} else {
console.error('Failed to delete Forward. ');
}
}).catch((err) => {
console.error('Failed to delete Forward: ' + JSON.stringify(err));
});
} catch (err) {
inputClient.deleteForward(length).then((result) => {
if (result) {
console.info('Succeeded in deleting forward. ');
} else {
console.error('Failed to delete Forward. ');
}
}).catch((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
```js
let length = 1;
try {
inputClient.deleteBackward(length, (err, result) => {
if (err !== undefined) {
console.error('Failed to delete Backward: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in deleting backward. ');
} else {
console.error('Failed to delete Backward: ' + JSON.stringify(err));
}
});
inputClient.deleteBackward(length, (err, result) => {
if (err) {
console.error('Failed to delete Backward: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in deleting backward. ');
} else {
console.error('Failed to delete Backward: ' + JSON.stringify(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;
```js
let length = 1;
inputClient.deleteBackward(length).then((result) => {
if (result) {
console.info('Succeeded in deleting backward. ');
} else {
console.error('Failed to deleteBackward. ');
}
if (result) {
console.info('Succeeded in deleting backward. ');
} else {
console.error('Failed to deleteBackward. ');
}
}).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
```js
inputClient.insertText('test', (err, result) => {
if (err !== undefined) {
console.error('Failed to insertText: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in inserting text. ');
} else {
console.error('Failed to insertText. ');
}
if (err) {
console.error('Failed to insertText: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in inserting text. ');
} else {
console.error('Failed to insertText. ');
}
});
```
......@@ -2016,17 +2018,17 @@ insertText(text:string): Promise&lt;boolean&gt;
```js
try {
inputClient.insertText('test').then((result) => {
if (result) {
console.info('Succeeded in inserting text. ');
} else {
console.error('Failed to insertText. ');
}
}).catch((err) => {
console.error('Failed to insertText: ' + JSON.stringify(err));
});
} catch (err) {
inputClient.insertText('test').then((result) => {
if (result) {
console.info('Succeeded in inserting text. ');
} else {
console.error('Failed to insertText. ');
}
}).catch((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
```js
inputClient.getEditorAttribute((err, editorAttribute) => {
if (err !== undefined) {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return;
}
console.log('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.log('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
if (err) {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return;
}
console.log('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.log('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
});
```
......@@ -2091,10 +2093,10 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
```js
inputClient.getEditorAttribute().then((editorAttribute) => {
console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
}).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
```js
try {
inputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err) => {
if (err !== undefined) {
console.error('Failed to moveCursor: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in moving cursor.');
});
inputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err) => {
if (err) {
console.error('Failed to moveCursor: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in moving cursor.');
});
} 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;
```js
try {
inputClient.moveCursor(inputMethodEngine.CURSOR_UP).then(() => {
console.log('Succeeded in moving cursor.');
}).catch((err) => {
console.error('Failed to moveCursor: ' + JSON.stringify(err));
});
inputClient.moveCursor(inputMethodEngine.CURSOR_UP).then(() => {
console.log('Succeeded in moving cursor.');
}).catch((err) => {
console.error('Failed to moveCursor: ' + JSON.stringify(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
```js
try {
inputClient.selectByRange({start: 0, end: 1}, (err) => {
if (err !== undefined) {
console.error('Failed to selectByRange: ${err.message}');
return;
}
console.info('Succeeded in selecting by range.');
});
inputClient.selectByRange({start: 0, end: 1}, (err) => {
if (err) {
console.error('Failed to selectByRange: ${err.message}');
return;
}
console.info('Succeeded in selecting by range.');
});
} 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;
```js
try {
inputClient.selectByRange({start: 0, end:1}).then(() => {
console.log('Succeeded in selecting by range.');
}).catch((err) => {
console.error('Failed to selectByRange: ${err.message}');
});
inputClient.selectByRange({start: 0, end:1}).then(() => {
console.log('Succeeded in selecting by range.');
}).catch((err) => {
console.error('Failed to selectByRange: ${err.message}');
});
} 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
```js
try {
inputClient.selectByMovement({direction: 1}, (err) => {
if (err !== undefined) {
console.error('Failed to selectByMovement: ${err.message}');
return;
}
console.info('Succeeded in selecting by movement.');
});
inputClient.selectByMovement({direction: 1}, (err) => {
if (err) {
console.error('Failed to selectByMovement: ${err.message}');
return;
}
console.info('Succeeded in selecting by movement.');
});
} 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;
```js
try {
inputClient.selectByMovement({direction: 1}).then(() => {
console.log('Succeeded in selecting by movement.');
}).catch((err) => {
console.error('Failed to selectByMovement: ${err.message}');
});
inputClient.selectByMovement({direction: 1}).then(() => {
console.log('Succeeded in selecting by movement.');
}).catch((err) => {
console.error('Failed to selectByMovement: ${err.message}');
});
} 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
```js
inputClient.getTextIndexAtCursor((err, index) => {
if (err !== undefined) {
console.error('Failed to getTextIndexAtCursor: ${err.message}');
return;
}
console.info('Succeeded in getTextIndexAtCursor: ' + index);
if (err) {
console.error('Failed to getTextIndexAtCursor: ${err.message}');
return;
}
console.info('Succeeded in getTextIndexAtCursor: ' + index);
});
```
......@@ -2407,9 +2409,9 @@ getTextIndexAtCursor(): Promise&lt;number&gt;
```js
inputClient.getTextIndexAtCursor().then((index) => {
console.info('Succeeded in getTextIndexAtCursor: ' + index);
console.info('Succeeded in getTextIndexAtCursor: ' + index);
}).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
```js
try {
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err) => {
if (err !== undefined) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in sending extend action.');
});
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err) => {
if (err) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
return;
}
console.info('Succeeded in sending extend action.');
});
} 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;
```js
try {
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY).then(() => {
console.info('Succeeded in sending extend action.');
}).catch((err) => {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
});
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY).then(() => {
console.info('Succeeded in sending extend action.');
}).catch((err) => {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
});
} 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
```js
let length = 1;
textInputClient.getForward(length, (err, text) => {
if (err !== undefined) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting forward, text: ' + text);
if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting forward, text: ' + text);
});
```
......@@ -2624,9 +2626,9 @@ getForward(length:number): Promise&lt;string&gt;
```js
let length = 1;
textInputClient.getForward(length).then((text) => {
console.info('Succeeded in getting forward, text: ' + text);
console.info('Succeeded in getting forward, text: ' + text);
}).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
```js
let length = 1;
textInputClient.getBackward(length, (err, text) => {
if (err !== undefined) {
console.error('Failed to getBackward: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting borward, text: ' + text);
if (err) {
console.error('Failed to getBackward: ' + JSON.stringify(err));
return;
}
console.log('Succeeded in getting borward, text: ' + text);
});
```
......@@ -2691,9 +2693,9 @@ getBackward(length:number): Promise&lt;string&gt;
```js
let length = 1;
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) => {
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
```js
let length = 1;
textInputClient.deleteForward(length, (err, result) => {
if (err !== undefined) {
console.error('Failed to deleteForward: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in deleting forward. ');
} else {
console.error('Failed to deleteForward. ');
}
if (err) {
console.error('Failed to deleteForward: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in deleting forward. ');
} else {
console.error('Failed to deleteForward. ');
}
});
```
......@@ -2762,13 +2764,13 @@ deleteForward(length:number): Promise&lt;boolean&gt;
```js
let length = 1;
textInputClient.deleteForward(length).then((result) => {
if (result) {
console.info('Succeeded in deleting forward. ');
} else {
console.error('Failed to delete forward. ');
}
if (result) {
console.info('Succeeded in deleting forward. ');
} else {
console.error('Failed to delete forward. ');
}
}).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
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------- |
| length | number | 是 | 文本长度。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。|
**示例:**
**示例:**
```js
let length = 1;
textInputClient.deleteBackward(length, (err, result) => {
if (err !== undefined) {
console.error('Failed to delete backward: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in deleting backward. ');
} else {
console.error('Failed to deleteBackward. ');
}
if (err) {
console.error('Failed to delete backward: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in deleting backward. ');
} else {
console.error('Failed to deleteBackward. ');
}
});
```
......@@ -2837,13 +2839,13 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
```js
let length = 1;
textInputClient.deleteBackward(length).then((result) => {
if (result) {
console.info('Succeeded in deleting backward. ');
} else {
console.error('Failed to deleteBackward. ');
}
if (result) {
console.info('Succeeded in deleting backward. ');
} else {
console.error('Failed to deleteBackward. ');
}
}).catch((err) => {
console.error('Failed to deleteBackward: ' + JSON.stringify(err));
console.error('Failed to deleteBackward: ' + JSON.stringify(err));
});
```
### sendKeyFunction<sup>(deprecated)</sup>
......@@ -2858,27 +2860,27 @@ sendKeyFunction(action: number, callback: AsyncCallback&lt;boolean&gt;): void
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**示例:**
**示例:**
```js
let action = 1;
textInputClient.sendKeyFunction(action, (err, result) => {
if (err !== undefined) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in sending key function. ');
} else {
console.error('Failed to sendKeyFunction. ');
}
if (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in sending key function. ');
} else {
console.error('Failed to sendKeyFunction. ');
}
});
```
......@@ -2911,13 +2913,13 @@ sendKeyFunction(action: number): Promise&lt;boolean&gt;
```js
let action = 1;
textInputClient.sendKeyFunction(action).then((result) => {
if (result) {
console.info('Succeeded in sending key function. ');
} else {
console.error('Failed to sendKeyFunction. ');
}
if (result) {
console.info('Succeeded in sending key function. ');
} else {
console.error('Failed to sendKeyFunction. ');
}
}).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
```js
textInputClient.insertText('test', (err, result) => {
if (err !== undefined) {
console.error('Failed to insertText: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in inserting text. ');
} else {
console.error('Failed to insertText. ');
}
if (err) {
console.error('Failed to insertText: ' + JSON.stringify(err));
return;
}
if (result) {
console.info('Succeeded in inserting text. ');
} else {
console.error('Failed to insertText. ');
}
});
```
......@@ -2984,13 +2986,13 @@ insertText(text:string): Promise&lt;boolean&gt;
```js
textInputClient.insertText('test').then((result) => {
if (result) {
console.info('Succeeded in inserting text. ');
} else {
console.error('Failed to insertText. ');
}
if (result) {
console.info('Succeeded in inserting text. ');
} else {
console.error('Failed to insertText. ');
}
}).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
```js
textInputClient.getEditorAttribute((err, editorAttribute) => {
if (err !== undefined) {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return;
}
console.log('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.log('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
if (err) {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return;
}
console.log('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.log('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
});
```
......@@ -3047,10 +3049,10 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
```js
textInputClient.getEditorAttribute().then((editorAttribute) => {
console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
console.info('editorAttribute.inputPattern: ' + JSON.stringify(editorAttribute.inputPattern));
console.info('editorAttribute.enterKeyType: ' + JSON.stringify(editorAttribute.enterKeyType));
}).catch((err) => {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
});
```
<!--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.
先完成此消息的编辑!
想要评论请 注册