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

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

Signed-off-by: NHollokin <taoyuxin2@huawei.com>
上级 2e52d650
......@@ -136,7 +136,7 @@ let prop = {
}
try{
inputMethod.switchInputMethod(prop, (err, result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
return;
}
......@@ -267,7 +267,7 @@ try {
iconId: 0,
extra: {}
}, (err, result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to switchCurrentInputMethodSubtype: ' + JSON.stringify(err));
return;
}
......@@ -395,7 +395,7 @@ let im = inputMethod.getCurrentInputMethod();
let imSubType = inputMethod.getCurrentInputMethodSubtype();
try {
inputMethod.switchCurrentInputMethodAndSubtype(im, imSubType, (err,result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to switchCurrentInputMethodAndSubtype: ' + JSON.stringify(err));
return;
}
......@@ -690,7 +690,7 @@ try {
}
};
inputMethodController.attach(true, textConfig, (err) => {
if (err !== undefined) {
if (err) {
console.error(`Failed to attach: ${JSON.stringify(err)}`);
return;
}
......@@ -783,7 +783,7 @@ showTextInput(callback: AsyncCallback&lt;void&gt;): void
```js
inputMethodController.showTextInput((err) => {
if (err !== undefined) {
if (err) {
console.error(`Failed to showTextInput: ${JSON.stringify(err)}`);
return;
}
......@@ -859,7 +859,7 @@ hideTextInput(callback: AsyncCallback&lt;void&gt;): void
```js
inputMethodController.hideTextInput((err) => {
if (err !== undefined) {
if (err) {
console.error(`Failed to hideTextInput: ${JSON.stringify(err)}`);
return;
}
......@@ -932,7 +932,7 @@ detach(callback: AsyncCallback&lt;void&gt;): void
```js
inputMethodController.detach((err) => {
if (err !== undefined) {
if (err) {
console.error(`Failed to detach: ${JSON.stringify(err)}`);
return;
}
......@@ -1006,7 +1006,7 @@ setCallingWindow(windowId: number, callback: AsyncCallback&lt;void&gt;): void
try {
let windowId: number = 2000;
inputMethodController.setCallingWindow(windowId, (err) => {
if (err !== undefined) {
if (err) {
console.error(`Failed to setCallingWindow: ${JSON.stringify(err)}`);
return;
}
......@@ -1096,7 +1096,7 @@ 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) {
if (err) {
console.error(`Failed to updateCursor: ${JSON.stringify(err)}`);
return;
}
......@@ -1185,7 +1185,7 @@ changeSelection(text: string, start: number, end: number, callback: AsyncCallbac
```js
try {
inputMethodController.changeSelection('text', 0, 5, (err) => {
if (err !== undefined) {
if (err) {
console.error(`Failed to changeSelection: ${JSON.stringify(err)}`);
return;
}
......@@ -1272,7 +1272,7 @@ updateAttribute(attribute: InputAttribute, callback: AsyncCallback&lt;void&gt;):
```js
try {
inputMethodController.updateAttribute({textInputType: 0, enterKeyType: 1}, (err) => {
if (err !== undefined) {
if (err) {
console.error(`Failed to updateAttribute: ${JSON.stringify(err)}`);
return;
}
......@@ -1357,7 +1357,7 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
```js
try {
inputMethodController.stopInputSession((error, result) => {
if (error !== undefined) {
if (error) {
console.error('Failed to stopInputSession: ' + JSON.stringify(error));
return;
}
......@@ -1446,7 +1446,7 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js
inputMethodController.showSoftKeyboard((err) => {
if (err === undefined) {
if (!err) {
console.info('Succeeded in showing softKeyboard.');
} else {
console.error('Failed to showSoftKeyboard: ' + JSON.stringify(err));
......@@ -1522,7 +1522,7 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js
inputMethodController.hideSoftKeyboard((err) => {
if (err === undefined) {
if (!err) {
console.info('Succeeded in hiding softKeyboard.');
} else {
console.error('Failed to hideSoftKeyboard: ' + JSON.stringify(err));
......@@ -1591,7 +1591,7 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
```js
inputMethodController.stopInput((error, result) => {
if (error !== undefined) {
if (error) {
console.error('Failed to stopInput: ' + JSON.stringify(error));
return;
}
......@@ -2146,7 +2146,7 @@ let inputMethodProperty = {
}
try {
inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => {
if (err !== undefined) {
if (err) {
console.error('Failed to listInputMethodSubtype: ' + JSON.stringify(err));
return;
}
......@@ -2235,7 +2235,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
```js
try {
inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if (err !== undefined) {
if (err) {
console.error('Failed to listCurrentInputMethodSubtype: ' + JSON.stringify(err));
return;
}
......@@ -2312,7 +2312,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
```js
try {
inputMethodSetting.getInputMethods(true, (err,data) => {
if (err !== undefined) {
if (err) {
console.error('Failed to getInputMethods: ' + JSON.stringify(err));
return;
}
......@@ -2393,7 +2393,7 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
```js
try {
inputMethodSetting.showOptionalInputMethods((err, data) => {
if (err !== undefined) {
if (err) {
console.error('Failed to showOptionalInputMethods: ' + JSON.stringify(err));
return;
}
......@@ -2458,7 +2458,7 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
```js
inputMethodSetting.listInputMethod((err,data) => {
if (err !== undefined) {
if (err) {
console.error('Failed to listInputMethod: ' + JSON.stringify(err));
return;
}
......@@ -2516,7 +2516,7 @@ displayOptionalInputMethod(callback: AsyncCallback&lt;void&gt;): void
```js
inputMethodSetting.displayOptionalInputMethod((err) => {
if (err !== undefined) {
if (err) {
console.error('Failed to displayOptionalInputMethod: ' + JSON.stringify(err));
return;
}
......
......@@ -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;
}
......@@ -837,7 +837,7 @@ on(type: 'textChange', callback: (text: string) => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本变化事件。<br/>-&nbsp;type为’textChange‘时,表示订阅文本变化事件。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。|
**示例:**
......@@ -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,7 +1353,7 @@ hide(callback: AsyncCallback&lt;void&gt;): void
```js
keyboardController.hide((err) => {
if (err !== undefined) {
if (err) {
console.error('Failed to hide keyboard: ' + JSON.stringify(err));
return;
}
......@@ -1413,7 +1415,7 @@ hideKeyboard(callback: AsyncCallback&lt;void&gt;): void
```js
keyboardController.hideKeyboard((err) => {
if (err !== undefined) {
if (err) {
console.error('Failed to hide Keyboard: ' + JSON.stringify(err));
return;
}
......@@ -1529,7 +1531,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
let action = 1;
try {
inputClient.sendKeyFunction(action, (err, result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return;
}
......@@ -1621,7 +1623,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
let length = 1;
try {
inputClient.getForward(length, (err, text) => {
if (err !== undefined) {
if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
......@@ -1706,7 +1708,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
let length = 1;
try {
inputClient.getBackward(length, (err, text) => {
if (err !== undefined) {
if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
......@@ -1791,7 +1793,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
let length = 1;
try {
inputClient.deleteForward(length, (err, result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to delete forward: ' + JSON.stringify(err));
return;
}
......@@ -1884,7 +1886,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
let length = 1;
try {
inputClient.deleteBackward(length, (err, result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to delete Backward: ' + JSON.stringify(err));
return;
}
......@@ -1971,7 +1973,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
```js
inputClient.insertText('test', (err, result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to insertText: ' + JSON.stringify(err));
return;
}
......@@ -2056,7 +2058,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
```js
inputClient.getEditorAttribute((err, editorAttribute) => {
if (err !== undefined) {
if (err) {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return;
}
......@@ -2126,7 +2128,7 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
```js
try {
inputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err) => {
if (err !== undefined) {
if (err) {
console.error('Failed to moveCursor: ' + JSON.stringify(err));
return;
}
......@@ -2208,7 +2210,7 @@ selectByRange(range: Range, callback: AsyncCallback&lt;void&gt;): void
```js
try {
inputClient.selectByRange({start: 0, end: 1}, (err) => {
if (err !== undefined) {
if (err) {
console.error('Failed to selectByRange: ${err.message}');
return;
}
......@@ -2291,7 +2293,7 @@ selectByMovement(movement: Movement, callback: AsyncCallback&lt;void&gt;): void
```js
try {
inputClient.selectByMovement({direction: 1}, (err) => {
if (err !== undefined) {
if (err) {
console.error('Failed to selectByMovement: ${err.message}');
return;
}
......@@ -2372,7 +2374,7 @@ getTextIndexAtCursor(callback: AsyncCallback&lt;number&gt;): void
```js
inputClient.getTextIndexAtCursor((err, index) => {
if (err !== undefined) {
if (err) {
console.error('Failed to getTextIndexAtCursor: ${err.message}');
return;
}
......@@ -2444,7 +2446,7 @@ sendExtendAction(action: ExtendAction, callback: AsyncCallback&lt;void&gt;): voi
```js
try {
inputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err) => {
if (err !== undefined) {
if (err) {
console.error(`Failed to sendExtendAction: ${JSON.stringify(err)}`);
return;
}
......@@ -2587,7 +2589,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js
let length = 1;
textInputClient.getForward(length, (err, text) => {
if (err !== undefined) {
if (err) {
console.error('Failed to getForward: ' + JSON.stringify(err));
return;
}
......@@ -2654,7 +2656,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
```js
let length = 1;
textInputClient.getBackward(length, (err, text) => {
if (err !== undefined) {
if (err) {
console.error('Failed to getBackward: ' + JSON.stringify(err));
return;
}
......@@ -2721,7 +2723,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
```js
let length = 1;
textInputClient.deleteForward(length, (err, result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to deleteForward: ' + JSON.stringify(err));
return;
}
......@@ -2784,19 +2786,19 @@ 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) {
if (err) {
console.error('Failed to delete backward: ' + JSON.stringify(err));
return;
}
......@@ -2858,19 +2860,19 @@ 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) {
if (err) {
console.error('Failed to sendKeyFunction: ' + JSON.stringify(err));
return;
}
......@@ -2944,7 +2946,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
```js
textInputClient.insertText('test', (err, result) => {
if (err !== undefined) {
if (err) {
console.error('Failed to insertText: ' + JSON.stringify(err));
return;
}
......@@ -3016,7 +3018,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
```js
textInputClient.getEditorAttribute((err, editorAttribute) => {
if (err !== undefined) {
if (err) {
console.error('Failed to getEditorAttribute: ' + JSON.stringify(err));
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册