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

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

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 2e52d650
...@@ -136,7 +136,7 @@ let prop = { ...@@ -136,7 +136,7 @@ let prop = {
} }
try{ try{
inputMethod.switchInputMethod(prop, (err, result) => { inputMethod.switchInputMethod(prop, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err)); console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
return; return;
} }
...@@ -267,7 +267,7 @@ try { ...@@ -267,7 +267,7 @@ try {
iconId: 0, iconId: 0,
extra: {} extra: {}
}, (err, result) => { }, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
...@@ -395,7 +395,7 @@ let im = inputMethod.getCurrentInputMethod(); ...@@ -395,7 +395,7 @@ let im = inputMethod.getCurrentInputMethod();
let imSubType = inputMethod.getCurrentInputMethodSubtype(); let imSubType = inputMethod.getCurrentInputMethodSubtype();
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => { inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => {
if (err !== undefined) { if (err) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err)); console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
return; return;
} }
...@@ -690,7 +690,7 @@ try { ...@@ -690,7 +690,7 @@ try {
} }
}; };
inputMethodController.attach(true, textConfig, (err) => { inputMethodController.attach(true, textConfig, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to attach: ${JSON.stringify(err)}`); console.error(`Failed to attach: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -783,7 +783,7 @@ showTextInput(callback: AsyncCallback&lt;void&gt;): void ...@@ -783,7 +783,7 @@ showTextInput(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.showTextInput((err) => { inputMethodController.showTextInput((err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to showTextInput: ${JSON.stringify(err)}`); console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -859,7 +859,7 @@ hideTextInput(callback: AsyncCallback&lt;void&gt;): void ...@@ -859,7 +859,7 @@ hideTextInput(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.hideTextInput((err) => { inputMethodController.hideTextInput((err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`); console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -932,7 +932,7 @@ detach(callback: AsyncCallback&lt;void&gt;): void ...@@ -932,7 +932,7 @@ detach(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.detach((err) => { inputMethodController.detach((err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to detach: ${JSON.stringify(err)}`); console.error(`Failed to detach: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -1006,7 +1006,7 @@ setCallingWindow(windowId: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -1006,7 +1006,7 @@ setCallingWindow(windowId: number, callback: AsyncCallback&lt;void&gt;): void
try { try {
let windowId: number = 2000; let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId, (err) => { inputMethodController.setCallingWindow(windowId, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`); console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -1096,7 +1096,7 @@ updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback&lt;void&gt;): void ...@@ -1096,7 +1096,7 @@ updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}, (err) => { inputMethodController.updateCursor({left: 0, top: 0, width: 600, height: 800}, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`); console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -1185,7 +1185,7 @@ changeSelection(text: string, start: number, end: number, callback: AsyncCallbac ...@@ -1185,7 +1185,7 @@ changeSelection(text: string, start: number, end: number, callback: AsyncCallbac
```js ```js
try { try {
inputMethodController.changeSelection('text', 0, 5, (err) => { inputMethodController.changeSelection('text', 0, 5, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`); console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -1272,7 +1272,7 @@ updateAttribute(attribute: InputAttribute, callback: AsyncCallback&lt;void&gt;): ...@@ -1272,7 +1272,7 @@ updateAttribute(attribute: InputAttribute, callback: AsyncCallback&lt;void&gt;):
```js ```js
try { try {
inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}, (err) => { inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`); console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -1357,7 +1357,7 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1357,7 +1357,7 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
try { try {
inputMethodController.stopInputSession((error, result) => { inputMethodController.stopInputSession((error, result) => {
if (error !== undefined) { if (error) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error)); console.error('Failed to stopInputSession: ' + JSON.stringify(error));
return; return;
} }
...@@ -1446,7 +1446,7 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -1446,7 +1446,7 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.showSoftKeyboard((err) => { inputMethodController.showSoftKeyboard((err) => {
if (err === undefined) { if (!err) {
console.info('Succeeded in showing softKeyboard.'); console.info('Succeeded in showing softKeyboard.');
} else { } else {
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err)); console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
...@@ -1522,7 +1522,7 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -1522,7 +1522,7 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodController.hideSoftKeyboard((err) => { inputMethodController.hideSoftKeyboard((err) => {
if (err === undefined) { if (!err) {
console.info('Succeeded in hiding softKeyboard.'); console.info('Succeeded in hiding softKeyboard.');
} else { } else {
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err)); console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
...@@ -1591,7 +1591,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1591,7 +1591,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
inputMethodController.stopInput((error, result) => { inputMethodController.stopInput((error, result) => {
if (error !== undefined) { if (error) {
console.error('Failed to stopInput: ' + JSON.stringify(error)); console.error('Failed to stopInput: ' + JSON.stringify(error));
return; return;
} }
...@@ -2146,7 +2146,7 @@ let inputMethodProperty = { ...@@ -2146,7 +2146,7 @@ let inputMethodProperty = {
} }
try { try {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => {
if (err !== undefined) { if (err) {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
...@@ -2235,7 +2235,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub ...@@ -2235,7 +2235,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
```js ```js
try { try {
inputMethodSetting.listCurrentInputMethodSubtype((err, data) => { inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err !== undefined) { if (err) {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err)); console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
return; return;
} }
...@@ -2312,7 +2312,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod ...@@ -2312,7 +2312,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
```js ```js
try { try {
inputMethodSetting.getInputMethods(true, (err,data) => { inputMethodSetting.getInputMethods(true, (err,data) => {
if (err !== undefined) { if (err) {
console.error('Failed to getInputMethods: ' + JSON.stringify(err)); console.error('Failed to getInputMethods: ' + JSON.stringify(err));
return; return;
} }
...@@ -2393,7 +2393,7 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2393,7 +2393,7 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
try { try {
inputMethodSetting.showOptionalInputMethods((err, data) => { inputMethodSetting.showOptionalInputMethods((err, data) => {
if (err !== undefined) { if (err) {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err)); console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
return; return;
} }
...@@ -2458,7 +2458,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;) ...@@ -2458,7 +2458,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
```js ```js
inputMethodSetting.listInputMethod((err,data) => { inputMethodSetting.listInputMethod((err,data) => {
if (err !== undefined) { if (err) {
console.error('Failed to listInputMethod: ' + JSON.stringify(err)); console.error('Failed to listInputMethod: ' + JSON.stringify(err));
return; return;
} }
...@@ -2516,7 +2516,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void ...@@ -2516,7 +2516,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
```js ```js
inputMethodSetting.displayOptionalInputMethod((err) => { inputMethodSetting.displayOptionalInputMethod((err) => {
if (err !== undefined) { if (err) {
console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err)); console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err));
return; return;
} }
......
...@@ -513,7 +513,7 @@ let panelInfo: inputMethodEngine.PanelInfo = { ...@@ -513,7 +513,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
} }
try { try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => { inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) { if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err)); console.log('Failed to create panel, err: ' + JSON.stringify(err));
return; return;
} }
...@@ -590,7 +590,7 @@ let panelInfo: inputMethodEngine.PanelInfo = { ...@@ -590,7 +590,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
} }
try { try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => { inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) { if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err)); console.log('Failed to create panel, err: ' + JSON.stringify(err));
return; return;
} }
...@@ -642,7 +642,7 @@ let panelInfo: inputMethodEngine.PanelInfo = { ...@@ -642,7 +642,7 @@ let panelInfo: inputMethodEngine.PanelInfo = {
} }
try { try {
inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => { inputMethodEngine.getInputMethodAbility().createPanel(this.context, panelInfo, (err, panel) => {
if (err !== undefined) { if (err) {
console.log('Failed to create panel, err: ' + JSON.stringify(err)); console.log('Failed to create panel, err: ' + JSON.stringify(err));
return; return;
} }
...@@ -837,7 +837,7 @@ on(type: 'textChange', callback: (text: string) => void): void ...@@ -837,7 +837,7 @@ on(type: 'textChange', callback: (text: string) => void): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本变化事件。<br/>-&nbsp;type为’textChange‘时,表示订阅文本变化事件。 | | type | string | 是 | 文本变化事件。<br/>-&nbsp;type为’textChange‘时,表示订阅文本变化事件。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。 | | callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。|
**示例:** **示例:**
...@@ -1017,6 +1017,7 @@ try { ...@@ -1017,6 +1017,7 @@ try {
resize(width: number, height: number, callback: AsyncCallback\<void>): void resize(width: number, height: number, callback: AsyncCallback\<void>): void
改变当前面板大小,使用callback异步回调。 改变当前面板大小,使用callback异步回调。
面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。 面板存在大小限制,面板宽度不超出屏幕宽度,面板高度不高于屏幕高度的二分之一。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1088,6 +1089,7 @@ try { ...@@ -1088,6 +1089,7 @@ try {
moveTo(x: number, y: number, callback: AsyncCallback\<void>): void moveTo(x: number, y: number, callback: AsyncCallback\<void>): void
移动面板位置,使用callback异步回调。 移动面板位置,使用callback异步回调。
对FLG_FIXED状态的panel不产生实际移动效果。 对FLG_FIXED状态的panel不产生实际移动效果。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1260,7 +1262,7 @@ promise.then(() => { ...@@ -1260,7 +1262,7 @@ promise.then(() => {
on(type: 'show' | 'hide', callback: () => void): void on(type: 'show' | 'hide', callback: () => void): void
监听当前面板状态,可监听面板类型为show或者hide, 使用callback异步回调。 监听当前面板状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1283,7 +1285,7 @@ panel.on('show', () => { ...@@ -1283,7 +1285,7 @@ panel.on('show', () => {
off(type: 'show' | 'hide', callback?: () => void): void off(type: 'show' | 'hide', callback?: () => void): void
取消监听当前面板状态,可取消监听的面板类型为show或者hide,使用callback异步回调。 取消监听当前面板状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
...@@ -1351,7 +1353,7 @@ hide(callback: AsyncCallback&lt;void&gt;): void ...@@ -1351,7 +1353,7 @@ hide(callback: AsyncCallback&lt;void&gt;): void
```js ```js
keyboardController.hide((err) => { keyboardController.hide((err) => {
if (err !== undefined) { if (err) {
console.error('Failed to hide keyboard: ' + JSON.stringify(err)); console.error('Failed to hide keyboard: ' + JSON.stringify(err));
return; return;
} }
...@@ -1413,7 +1415,7 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void ...@@ -1413,7 +1415,7 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js ```js
keyboardController.hideKeyboard((err) => { keyboardController.hideKeyboard((err) => {
if (err !== undefined) { if (err) {
console.error('Failed to hide Keyboard: ' + JSON.stringify(err)); console.error('Failed to hide Keyboard: ' + JSON.stringify(err));
return; return;
} }
...@@ -1529,7 +1531,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1529,7 +1531,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
let action = 1; let action = 1;
try { try {
inputClient.sendKeyFunction(action, (err, result) => { inputClient.sendKeyFunction(action, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err)); console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return; return;
} }
...@@ -1621,7 +1623,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1621,7 +1623,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
let length = 1; let length = 1;
try { try {
inputClient.getForward(length, (err, text) => { inputClient.getForward(length, (err, text) => {
if (err !== undefined) { if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
...@@ -1706,7 +1708,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -1706,7 +1708,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
let length = 1; let length = 1;
try { try {
inputClient.getBackward(length, (err, text) => { inputClient.getBackward(length, (err, text) => {
if (err !== undefined) { if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
...@@ -1791,7 +1793,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1791,7 +1793,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
let length = 1; let length = 1;
try { try {
inputClient.deleteForward(length, (err, result) => { inputClient.deleteForward(length, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to delete forward: ' + JSON.stringify(err)); console.error('Failed to delete forward: ' + JSON.stringify(err));
return; return;
} }
...@@ -1884,7 +1886,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1884,7 +1886,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
let length = 1; let length = 1;
try { try {
inputClient.deleteBackward(length, (err, result) => { inputClient.deleteBackward(length, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to delete Backward: ' + JSON.stringify(err)); console.error('Failed to delete Backward: ' + JSON.stringify(err));
return; return;
} }
...@@ -1971,7 +1973,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -1971,7 +1973,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
inputClient.insertText('test', (err, result) => { inputClient.insertText('test', (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to insertText: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
return; return;
} }
...@@ -2056,7 +2058,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -2056,7 +2058,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
```js ```js
inputClient.getEditorAttribute((err, editorAttribute) => { inputClient.getEditorAttribute((err, editorAttribute) => {
if (err !== undefined) { if (err) {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return; return;
} }
...@@ -2126,7 +2128,7 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -2126,7 +2128,7 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err) => { inputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err) => {
if (err !== undefined) { if (err) {
console.error('Failed to moveCursor: ' + JSON.stringify(err)); console.error('Failed to moveCursor: ' + JSON.stringify(err));
return; return;
} }
...@@ -2208,7 +2210,7 @@ selectByRange(range: Range, callback: AsyncCallback&lt;void&gt;): void ...@@ -2208,7 +2210,7 @@ selectByRange(range: Range, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputClient.selectByRange({start: 0, end: 1}, (err) => { inputClient.selectByRange({start: 0, end: 1}, (err) => {
if (err !== undefined) { if (err) {
console.error('Failed to selectByRange: ${err.message}'); console.error('Failed to selectByRange: ${err.message}');
return; return;
} }
...@@ -2291,7 +2293,7 @@ selectByMovement(movement: Movement, callback: AsyncCallback&lt;void&gt;): void ...@@ -2291,7 +2293,7 @@ selectByMovement(movement: Movement, callback: AsyncCallback&lt;void&gt;): void
```js ```js
try { try {
inputClient.selectByMovement({direction: 1}, (err) => { inputClient.selectByMovement({direction: 1}, (err) => {
if (err !== undefined) { if (err) {
console.error('Failed to selectByMovement: ${err.message}'); console.error('Failed to selectByMovement: ${err.message}');
return; return;
} }
...@@ -2372,7 +2374,7 @@ getTextIndexAtCursor(callback: AsyncCallback&lt;number&gt;): void ...@@ -2372,7 +2374,7 @@ getTextIndexAtCursor(callback: AsyncCallback&lt;number&gt;): void
```js ```js
inputClient.getTextIndexAtCursor((err, index) => { inputClient.getTextIndexAtCursor((err, index) => {
if (err !== undefined) { if (err) {
console.error('Failed to getTextIndexAtCursor: ${err.message}'); console.error('Failed to getTextIndexAtCursor: ${err.message}');
return; return;
} }
...@@ -2444,7 +2446,7 @@ sendExtendAction(action: ExtendAction, callback: AsyncCallback&lt;void&gt;): voi ...@@ -2444,7 +2446,7 @@ sendExtendAction(action: ExtendAction, callback: AsyncCallback&lt;void&gt;): voi
```js ```js
try { try {
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err) => { inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err) => {
if (err !== undefined) { if (err) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`); console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
return; return;
} }
...@@ -2587,7 +2589,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -2587,7 +2589,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js ```js
let length = 1; let length = 1;
textInputClient.getForward(length, (err, text) => { textInputClient.getForward(length, (err, text) => {
if (err !== undefined) { if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err)); console.error('Failed to getForward: ' + JSON.stringify(err));
return; return;
} }
...@@ -2654,7 +2656,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void ...@@ -2654,7 +2656,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js ```js
let length = 1; let length = 1;
textInputClient.getBackward(length, (err, text) => { textInputClient.getBackward(length, (err, text) => {
if (err !== undefined) { if (err) {
console.error('Failed to getBackward: ' + JSON.stringify(err)); console.error('Failed to getBackward: ' + JSON.stringify(err));
return; return;
} }
...@@ -2721,7 +2723,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2721,7 +2723,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
let length = 1; let length = 1;
textInputClient.deleteForward(length, (err, result) => { textInputClient.deleteForward(length, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to deleteForward: ' + JSON.stringify(err)); console.error('Failed to deleteForward: ' + JSON.stringify(err));
return; return;
} }
...@@ -2784,19 +2786,19 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2784,19 +2786,19 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------- | | -------- | ---------------------------- | ---- | -------------- |
| length | number | 是 | 文本长度。 | | length | number | 是 | 文本长度。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。| | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当光标后固定长度的文本删除成功,err为undefined,data为true;否则为错误对象。|
**示例:** **示例:**
```js ```js
let length = 1; let length = 1;
textInputClient.deleteBackward(length, (err, result) => { textInputClient.deleteBackward(length, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to delete backward: ' + JSON.stringify(err)); console.error('Failed to delete backward: ' + JSON.stringify(err));
return; return;
} }
...@@ -2858,19 +2860,19 @@ sendKeyFunction(action: number, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2858,19 +2860,19 @@ sendKeyFunction(action: number, callback: AsyncCallback&lt;boolean&gt;): void
**系统能力:** SystemCapability.MiscServices.InputMethodFramework **系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 | | action | number | 是 | 功能键键值。<br/>当值为0时,表示无效按键;<br/>当值为1时,表示确认键(即回车键)。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数。当功能键发送成功,err为undefined,data为true;否则为错误对象。 |
**示例:** **示例:**
```js ```js
let action = 1; let action = 1;
textInputClient.sendKeyFunction(action, (err, result) => { textInputClient.sendKeyFunction(action, (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err)); console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return; return;
} }
...@@ -2944,7 +2946,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void ...@@ -2944,7 +2946,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
```js ```js
textInputClient.insertText('test', (err, result) => { textInputClient.insertText('test', (err, result) => {
if (err !== undefined) { if (err) {
console.error('Failed to insertText: ' + JSON.stringify(err)); console.error('Failed to insertText: ' + JSON.stringify(err));
return; return;
} }
...@@ -3016,7 +3018,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void ...@@ -3016,7 +3018,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
```js ```js
textInputClient.getEditorAttribute((err, editorAttribute) => { textInputClient.getEditorAttribute((err, editorAttribute) => {
if (err !== undefined) { if (err) {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err)); console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册