1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import inputMethodEngine from '@ohos.inputMethodEngine'; 16import display from '@ohos.display'; 17import windowManager from '@ohos.window'; 18import promptAction from '@ohos.promptAction'; 19import commoneventmanager from '@ohos.commonEventManager'; 20 21let inputMethodAbility = inputMethodEngine.getInputMethodAbility(); 22let inputKeyboardDelegate = inputMethodEngine.getKeyboardDelegate(); 23 24const TAG = 'KeyboardDelegate'; 25 26export class KeyboardDelegate { 27 mContext; 28 WINDOW_TYPE_INPUT_METHOD_FLOAT = 2105; 29 windowName = 'inputApp'; 30 private windowHeight: number = 0; 31 private windowWidth: number = 0; 32 private nonBarPosition: number = 0; 33 34 constructor(context) { 35 this.mContext = context; 36 } 37 38 private onInputStop() { 39 try{ 40 this.mContext.destroy((err) => { 41 console.info(TAG + '====>inputMethodEngine destroy err:' + JSON.stringify(err)); 42 }) 43 }catch(err){ 44 console.info(TAG + '====>inputMethodEngine destroy catch err:' + JSON.stringify(err)); 45 } 46 } 47 48 public onCreate(): void { 49 this.initWindow(); 50 let that = this; 51 this.onInputStop = this.onInputStop.bind(this) 52 inputMethodAbility.on('inputStop', this.onInputStop) 53 54 function subscriberCallback(err, data) { 55 console.debug(TAG + '====>receive event err:' + JSON.stringify(err)); 56 console.debug(TAG + '====>receive event data:' + JSON.stringify(data)); 57 switch (data.code) { 58 case 1: 59 console.debug(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 event:' + data.event); 60 that.inputMethodAbility_test_getInputMethodAbility_001(); 61 break; 62 case 2: 63 console.debug(TAG + '====>inputMethodAbility_test_getInputMethodDelegate_001 event:' + data.event); 64 that.inputMethodAbility_test_getKeyboardDelegate_001(); 65 break; 66 case 28: 67 console.debug(TAG + '====>inputMethodAbility_test_028 event:' + data.event); 68 that.inputMethodAbility_test_028(); 69 break; 70 case 29: 71 console.debug(TAG + '====>inputMethodAbility_test_029 event:' + data.event); 72 that.inputMethodAbility_test_029(); 73 break; 74 case 30: 75 console.debug(TAG + '====>inputMethodAbility_test_030 event:' + data.event); 76 that.inputMethodAbility_test_030(); 77 break; 78 case 31: 79 console.debug(TAG + '====>inputMethodAbility_test_031 event:' + data.event); 80 that.inputMethodAbility_test_031(); 81 break; 82 case 32: 83 console.debug(TAG + '====>inputMethodAbility_test_032 event:' + data.event); 84 that.inputMethodAbility_test_032(); 85 break; 86 case 33: 87 console.debug(TAG + '====>inputMethodAbility_test_033 event:' + data.event); 88 that.inputMethodAbility_test_033(); 89 break; 90 case 34: 91 console.debug(TAG + '====>inputMethodAbility_test_034 event:' + data.event); 92 that.inputMethodAbility_test_034(); 93 break; 94 case 35: 95 console.debug(TAG + '====>inputMethodAbility_test_035 event:' + data.event); 96 that.inputMethodAbility_test_035(); 97 break; 98 case 36: 99 console.debug(TAG + '====>inputMethodAbility_test_036 event:' + data.event); 100 that.inputMethodAbility_test_036(); 101 break; 102 case 37: 103 console.debug(TAG + '====>inputMethodAbility_test_037 event:' + data.event); 104 that.inputMethodAbility_test_037(); 105 break; 106 case 38: 107 console.debug(TAG + '====>inputMethodAbility_test_038 event:' + data.event); 108 that.inputMethodAbility_test_038(); 109 break; 110 case 39: 111 console.debug(TAG + '====>inputMethodAbility_test_039 event:' + data.event); 112 that.inputMethodAbility_test_039(); 113 break; 114 case 40: 115 console.debug(TAG + '====>inputMethodAbility_test_040 event:' + data.event); 116 that.inputMethodAbility_test_040(); 117 break; 118 case 41: 119 console.debug(TAG + '====>inputMethodAbility_test_041 event:' + data.event); 120 that.inputMethodAbility_test_041(); 121 break; 122 case 42: 123 console.debug(TAG + '====>inputMethodAbility_test_042 event:' + data.event); 124 that.inputMethodAbility_test_042(); 125 break; 126 case 43: 127 console.debug(TAG + '====>inputMethodAbility_test_043 event:' + data.event); 128 that.inputMethodAbility_test_043(); 129 break; 130 case 45: 131 console.debug(TAG + '====>inputMethodAbility_test_045 event:' + data.event); 132 that.inputMethodAbility_test_045(); 133 break; 134 case 46: 135 console.debug(TAG + '====>inputMethodAbility_test_046 event:' + data.event); 136 that.inputMethodAbility_test_046(); 137 break; 138 case 47: 139 console.debug(TAG + '====>inputMethodAbility_test_047 event:' + data.event); 140 that.inputMethodAbility_test_047(); 141 break; 142 case 48: 143 console.debug(TAG + '====>inputMethodAbility_test_048 event:' + data.event); 144 that.inputMethodAbility_test_048(); 145 break; 146 case 49: 147 console.debug(TAG + '====>inputMethodAbility_test_049 event:' + data.event); 148 that.inputMethodAbility_test_049(); 149 break; 150 case 50: 151 console.debug(TAG + '====>inputMethodAbility_test_050 event:' + data.event); 152 that.inputMethodAbility_test_050(); 153 break; 154 case 70: 155 console.debug(TAG + '====>inputMethodAbility_test_070 event:' + data.event); 156 that.inputMethodAbility_test_070(); 157 break; 158 case 71: 159 console.debug(TAG + '====>inputMethodAbility_test_071 event:' + data.event); 160 that.inputMethodAbility_test_071(); 161 break; 162 case 72: 163 console.debug(TAG + '====>inputMethodAbility_test_072 event:' + data.event); 164 that.inputMethodAbility_test_072(); 165 break; 166 case 73: 167 console.debug(TAG + '====>inputMethodAbility_test_073 event:' + data.event); 168 that.inputMethodAbility_test_073(); 169 break; 170 case 74: 171 console.debug(TAG + '====>inputMethodAbility_test_074 event:' + data.event); 172 that.inputMethodAbility_test_074(); 173 break; 174 case 91: 175 console.debug(TAG + '====>inputMethodAbility_test_091 event:' + data.event); 176 that.inputMethodAbility_test_091(); 177 break; 178 case 101: 179 console.debug(TAG + '====>inputMethodAbility_test_0101 event:' + data.event); 180 that.inputMethodAbility_test_101(); 181 break; 182 case 102: 183 console.debug(TAG + '====>inputMethodAbility_test_0102 event:' + data.event); 184 that.inputMethodAbility_test_102(); 185 break; 186 case 103: 187 console.debug(TAG + '====>inputMethodAbility_test_0103 event:' + data.event); 188 that.inputMethodAbility_test_103(); 189 break; 190 case 104: 191 console.debug(TAG + '====>inputMethodAbility_test_0104 event:' + data.event); 192 that.inputMethodAbility_test_104(); 193 break; 194 case 105: 195 console.debug(TAG + '====>inputMethodAbility_test_0105 event:' + data.event); 196 that.inputMethodAbility_test_105(); 197 break; 198 case 106: 199 console.debug(TAG + '====>inputMethodAbility_test_0106 event:' + data.event); 200 that.inputMethodAbility_test_106(); 201 break; 202 case 110: 203 console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 event:' + data.event); 204 that.Sub_Misc_inputMethod_onSelectByRange_0110(); 205 break; 206 case 120: 207 console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 event:' + data.event); 208 that.Sub_Misc_inputMethod_onSelectByMovement_0120(); 209 break; 210 case 130: 211 console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByRange_0130 event:' + data.event); 212 that.Sub_Misc_inputMethod_offSelectByRange_0130(); 213 break; 214 case 140: 215 console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 event:' + data.event); 216 that.Sub_Misc_inputMethod_offSelectByMovement_0140(); 217 break; 218 case 170: 219 console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 event:' + data.event); 220 that.Sub_Misc_inputMethod_sendExtendAction_0170(); 221 break; 222 case 180: 223 console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 event:' + data.event); 224 that.Sub_Misc_inputMethod_sendExtendAction_0180(); 225 break; 226 case 200: 227 console.debug(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0200 event:' + data.event); 228 that.Sub_Misc_inputMethod_getForward_sync_0200(); 229 break; 230 case 201: 231 console.debug(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0201 event:' + data.event); 232 that.Sub_Misc_inputMethod_getForward_sync_0201(); 233 break; 234 case 210: 235 console.debug(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0210 event:' + data.event); 236 that.Sub_Misc_inputMethod_getBackward_sync_0210(); 237 break; 238 case 211: 239 console.debug(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0211 event:' + data.event); 240 that.Sub_Misc_inputMethod_getBackward_sync_0211(); 241 break; 242 case 220: 243 console.debug(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220 event:' + data.event); 244 that.Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220(); 245 break; 246 case 221: 247 console.debug(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221 event:' + data.event); 248 that.Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221(); 249 break; 250 case 230: 251 console.debug(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0230 event:' + data.event); 252 that.Sub_Misc_inputMethod_getEditorAttribute_sync_0230(); 253 break; 254 case 231: 255 console.debug(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0231 event:' + data.event); 256 that.Sub_Misc_inputMethod_getEditorAttribute_sync_0231(); 257 break; 258 case 240: 259 console.debug(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0240 event:' + data.event); 260 that.Sub_Misc_inputMethod_moveCursor_sync_0240(); 261 break; 262 case 241: 263 console.debug(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0241 event:' + data.event); 264 that.Sub_Misc_inputMethod_moveCursor_sync_0241(); 265 break; 266 case 250: 267 console.debug(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0250 event:' + data.event); 268 that.Sub_Misc_inputMethod_deleteForward_sync_0250(); 269 break; 270 case 251: 271 console.debug(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0251 event:' + data.event); 272 that.Sub_Misc_inputMethod_deleteForward_sync_0251(); 273 break; 274 case 260: 275 console.debug(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0260 event:' + data.event); 276 that.Sub_Misc_inputMethod_deleteBackward_sync_0260(); 277 break; 278 case 261: 279 console.debug(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0261 event:' + data.event); 280 that.Sub_Misc_inputMethod_deleteBackward_sync_0261(); 281 break; 282 case 270: 283 console.debug(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0270 event:' + data.event); 284 that.Sub_Misc_inputMethod_insertText_sync_0270(); 285 break; 286 case 271: 287 console.debug(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0271 event:' + data.event); 288 that.Sub_Misc_inputMethod_insertText_sync_0271(); 289 break; 290 case 280: 291 console.debug(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0280 event:' + data.event); 292 that.Sub_Misc_inputMethod_selectByRange_sync_0280(); 293 break; 294 case 281: 295 console.debug(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0281 event:' + data.event); 296 that.Sub_Misc_inputMethod_selectByRange_sync_0281(); 297 break; 298 case 290: 299 console.debug(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0290 event:' + data.event); 300 that.Sub_Misc_inputMethod_selectByMovement_sync_0290(); 301 break; 302 case 291: 303 console.debug(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0291 event:' + data.event); 304 that.Sub_Misc_inputMethod_selectByMovement_sync_0291(); 305 break; 306 } 307 } 308 309 var commonEventSubscribeInfo = { 310 events: ["test"] 311 }; 312 313 var subscriber; 314 commoneventmanager.createSubscriber(commonEventSubscribeInfo).then(function (data) { 315 subscriber = data; 316 commoneventmanager.subscribe(subscriber, subscriberCallback); 317 console.debug(TAG + '====>scene subscribe finish===='); 318 }); 319 } 320 321 public initWindow(): void { 322 let dis = display.getDefaultDisplaySync(); 323 var dWidth = dis.width; 324 var dHeight = dis.height; 325 var keyHeightRate = 0.47; 326 var keyHeight = dHeight * keyHeightRate; 327 this.windowWidth = dWidth; 328 this.windowHeight = keyHeight; 329 this.nonBarPosition = dHeight - keyHeight; 330 331 var config = { 332 name: this.windowName, 333 windowType: this.WINDOW_TYPE_INPUT_METHOD_FLOAT, 334 cts: this.mContext 335 }; 336 337 windowManager.createWindow(config).then((win) => { 338 win.resize(dWidth, keyHeight).then(() => { 339 win.moveWindowTo(0, this.nonBarPosition).then(() => { 340 win.setUIContent('page/service/index').then(() => { 341 }); 342 }); 343 }); 344 }); 345 } 346 347 public onDestroy(): void { 348 console.debug(TAG + '====>onDestroy'); 349 inputMethodAbility.off('inputStop', this.onInputStop) 350 351 } 352 353 private publishCallback(err): void { 354 if (err) { 355 console.error(TAG + '====>publish failed:' + JSON.stringify(err)); 356 } else { 357 console.debug(TAG + '====>publish'); 358 } 359 } 360 361 public async offInputStop_test() { 362 console.info(TAG + '====>inputMethodAbility_test_091.offInputStop_test callback'); 363 let commonEventPublishData = { 364 data: "FAILED" 365 }; 366 this.mContext.destroy((err) => { 367 console.info(TAG + '====>inputMethodAbility offInputStop_test destroy err: ' + JSON.stringify(err)); 368 commoneventmanager.publish("inputMethodAbility_test_091", commonEventPublishData,() => {}); 369 }) 370 } 371 372 public inputMethodAbility_test_091(): void{ 373 console.info(TAG + '====>inputMethodAbility_test_091 start'); 374 this.offInputStop_test = this.offInputStop_test.bind(this); 375 inputMethodAbility.on("inputStop",this.offInputStop_test); 376 inputMethodAbility.off("inputStop",this.offInputStop_test); 377 console.info(TAG + '====>inputMethodAbility_test_091 end'); 378 } 379 380 private inputMethodAbility_test_getInputMethodAbility_001(): void { 381 console.debug(TAG + '====>receive inputMethodAbility_test_getInputMethodAbility_001 data'); 382 if (typeof(inputMethodAbility) === 'object') { 383 console.debug(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 success'); 384 var commonEventPublishData = { 385 data: "SUCCESS" 386 }; 387 } else { 388 console.debug(TAG + '====>inputMethodAbility_test_getInputMethodAbility_001 failed'); 389 var commonEventPublishData = { 390 data: "FAILED" 391 }; 392 } 393 commoneventmanager.publish("inputMethodAbility_test_getInputMethodAbility_001", commonEventPublishData, this.publishCallback); 394 } 395 396 private inputMethodAbility_test_getKeyboardDelegate_001(): void { 397 console.debug(TAG + '====>receive inputMethodAbility_test_getKeyboardDelegate_001 data'); 398 if (typeof (inputKeyboardDelegate) === 'object') { 399 console.debug(TAG + '====>inputMethodAbility_test_getKeyboardDelegate_001 success'); 400 var commonEventPublishData = { 401 data: "SUCCESS" 402 }; 403 } else { 404 console.debug(TAG + '====>inputMethodAbility_test_getKeyboardDelegate_001 failed'); 405 var commonEventPublishData = { 406 data: "FAILED" 407 }; 408 } 409 commoneventmanager.publish("inputMethodAbility_test_getKeyboardDelegate_001", commonEventPublishData, this.publishCallback); 410 } 411 412 private inputMethodAbility_test_028(): void { 413 console.debug(TAG + '====>receive inputMethodAbility_test_028 data'); 414 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 415 inputMethodAbility.off('inputStart'); 416 let commonEventPublishData; 417 if (InputClient == null) { 418 commonEventPublishData = { 419 data: "FAILED" 420 }; 421 commoneventmanager.publish("inputMethodAbility_test_028", commonEventPublishData, this.publishCallback); 422 } else { 423 let editorAttribyte = await InputClient.getEditorAttribute(); 424 console.debug(TAG + '====>inputMethodAbility_test_028 editorAttribyte:' + JSON.stringify(editorAttribyte)); 425 InputClient.sendKeyFunction(editorAttribyte.enterKeyType, (err, value) => { 426 if (err) { 427 console.debug(TAG + '====>inputMethodAbility_test_028 sendKeyFunction err:' + JSON.stringify(err)); 428 commonEventPublishData = { 429 data: "FAILED" 430 }; 431 } else { 432 console.debug(TAG + '====>inputMethodAbility_test_028 sendKeyFunction value:' + JSON.stringify(value)); 433 if (value) { 434 commonEventPublishData = { 435 data: "SUCCESS" 436 }; 437 } else { 438 commonEventPublishData = { 439 data: "FAILED" 440 }; 441 } 442 } 443 commoneventmanager.publish("inputMethodAbility_test_028", commonEventPublishData, this.publishCallback); 444 }); 445 } 446 }); 447 } 448 449 private inputMethodAbility_test_029(): void { 450 console.debug(TAG + '====>receive inputMethodAbility_test_029 data'); 451 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 452 inputMethodAbility.off('inputStart'); 453 let commonEventPublishData; 454 if (InputClient == null) { 455 commonEventPublishData = { 456 data: "FAILED" 457 }; 458 commoneventmanager.publish("inputMethodAbility_test_029", commonEventPublishData, this.publishCallback); 459 } else { 460 let editorAttribyte = await InputClient.getEditorAttribute(); 461 console.debug(TAG + '====>inputMethodAbility_test_029 editorAttribyte:' + JSON.stringify(editorAttribyte)); 462 let value = InputClient.sendKeyFunction(editorAttribyte.enterKeyType); 463 console.debug(TAG + '====>inputMethodAbility_test_029 sendKeyFunction value:' + JSON.stringify(value)); 464 if (value) { 465 commonEventPublishData = { 466 data: "SUCCESS" 467 }; 468 } else { 469 commonEventPublishData = { 470 data: "FAILED" 471 }; 472 } 473 commoneventmanager.publish("inputMethodAbility_test_029", commonEventPublishData, this.publishCallback); 474 } 475 }); 476 } 477 478 private inputMethodAbility_test_030(): void { 479 console.debug(TAG + '====>receive inputMethodAbility_test_030 data'); 480 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 481 inputMethodAbility.off('inputStart'); 482 let commonEventPublishData; 483 if (InputClient == null) { 484 commonEventPublishData = { 485 data: "FAILED" 486 }; 487 commoneventmanager.publish("inputMethodAbility_test_030", commonEventPublishData, this.publishCallback); 488 } else { 489 InputClient.deleteForward(1, (err, value) => { 490 if (err) { 491 console.debug(TAG + '====>inputMethodAbility_test_030 deleteForward err:' + JSON.stringify(err)); 492 commonEventPublishData = { 493 data: "FAILED" 494 }; 495 } else { 496 console.debug(TAG + '====>inputMethodAbility_test_030 deleteForward value:' + JSON.stringify(value)); 497 if (typeof value === 'boolean') { 498 commonEventPublishData = { 499 data: "SUCCESS" 500 }; 501 } else { 502 commonEventPublishData = { 503 data: "FAILED" 504 }; 505 } 506 } 507 commoneventmanager.publish("inputMethodAbility_test_030", commonEventPublishData, this.publishCallback); 508 }); 509 } 510 }); 511 } 512 513 private inputMethodAbility_test_031(): void { 514 console.debug(TAG + '====>receive inputMethodAbility_test_031 data'); 515 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 516 inputMethodAbility.off('inputStart'); 517 let commonEventPublishData; 518 if (InputClient == null) { 519 commonEventPublishData = { 520 data: "FAILED" 521 }; 522 commoneventmanager.publish("inputMethodAbility_test_031", commonEventPublishData, this.publishCallback); 523 } else { 524 let value = await InputClient.deleteForward(1); 525 console.debug(TAG + '====>inputMethodAbility_test_031 deleteForward value:' + value); 526 if (typeof value === 'boolean') { 527 commonEventPublishData = { 528 data: "SUCCESS" 529 }; 530 } else { 531 commonEventPublishData = { 532 data: "FAILED" 533 }; 534 } 535 commoneventmanager.publish("inputMethodAbility_test_031", commonEventPublishData, this.publishCallback); 536 } 537 }); 538 } 539 540 private inputMethodAbility_test_032(): void { 541 console.debug(TAG + '====>receive inputMethodAbility_test_032 data'); 542 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 543 inputMethodAbility.off('inputStart'); 544 let commonEventPublishData; 545 if (InputClient == null) { 546 commonEventPublishData = { 547 data: "FAILED" 548 }; 549 commoneventmanager.publish("inputMethodAbility_test_032", commonEventPublishData, this.publishCallback); 550 } else { 551 InputClient.deleteBackward(1, (err, value) => { 552 if (err) { 553 console.debug(TAG + '====>inputMethodAbility_test_032 deleteBackward err:' + JSON.stringify(err)); 554 commonEventPublishData = { 555 data: "FAILED" 556 }; 557 } else { 558 console.debug(TAG + '====>inputMethodAbility_test_032 deleteBackward value:' + JSON.stringify(value)); 559 if (value) { 560 commonEventPublishData = { 561 data: "SUCCESS" 562 }; 563 } else { 564 commonEventPublishData = { 565 data: "FAILED" 566 }; 567 } 568 } 569 commoneventmanager.publish("inputMethodAbility_test_032", commonEventPublishData, this.publishCallback); 570 }); 571 } 572 }); 573 } 574 575 private inputMethodAbility_test_033(): void { 576 console.debug(TAG + '====>receive inputMethodAbility_test_033 data'); 577 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 578 inputMethodAbility.off('inputStart'); 579 let commonEventPublishData; 580 if (InputClient == null) { 581 commonEventPublishData = { 582 data: "FAILED" 583 }; 584 commoneventmanager.publish("inputMethodAbility_test_033", commonEventPublishData, this.publishCallback); 585 } else { 586 let value = await InputClient.deleteBackward(1); 587 console.debug(TAG + '====>inputMethodAbility_test_033 deleteBackward value:' + JSON.stringify(value)); 588 if (value) { 589 commonEventPublishData = { 590 data: "SUCCESS" 591 }; 592 } else { 593 commonEventPublishData = { 594 data: "FAILED" 595 }; 596 } 597 commoneventmanager.publish("inputMethodAbility_test_033", commonEventPublishData, this.publishCallback); 598 } 599 }); 600 } 601 602 private inputMethodAbility_test_034(): void { 603 console.debug(TAG + '====>receive inputMethodAbility_test_034 data'); 604 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 605 inputMethodAbility.off('inputStart'); 606 let commonEventPublishData; 607 if (InputClient == null) { 608 commonEventPublishData = { 609 data: "FAILED" 610 }; 611 commoneventmanager.publish("inputMethodAbility_test_034", commonEventPublishData, this.publishCallback); 612 } else { 613 InputClient.insertText('test', (err, value) => { 614 if (err) { 615 console.debug(TAG + '====>inputMethodAbility_test_034 insertText err:' + JSON.stringify(err)); 616 commonEventPublishData = { 617 data: "FAILED" 618 }; 619 } else { 620 console.debug(TAG + '====>inputMethodAbility_test_034 insertText value:' + JSON.stringify(value)); 621 if (value) { 622 commonEventPublishData = { 623 data: "SUCCESS" 624 }; 625 } else { 626 commonEventPublishData = { 627 data: "FAILED" 628 }; 629 } 630 } 631 commoneventmanager.publish("inputMethodAbility_test_034", commonEventPublishData, this.publishCallback); 632 }); 633 } 634 }); 635 } 636 637 private inputMethodAbility_test_035(): void { 638 console.debug(TAG + '====>receive inputMethodAbility_test_035 data'); 639 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 640 inputMethodAbility.off('inputStart'); 641 let commonEventPublishData; 642 if (InputClient == null) { 643 commonEventPublishData = { 644 data: "FAILED" 645 }; 646 commoneventmanager.publish("inputMethodAbility_test_035", commonEventPublishData, this.publishCallback); 647 } else { 648 let value = await InputClient.insertText('test'); 649 console.debug(TAG + '====>inputMethodAbility_test_035 insertText value:' + JSON.stringify(value)); 650 if (value) { 651 commonEventPublishData = { 652 data: "SUCCESS" 653 }; 654 } else { 655 commonEventPublishData = { 656 data: "FAILED" 657 }; 658 } 659 commoneventmanager.publish("inputMethodAbility_test_035", commonEventPublishData, this.publishCallback); 660 } 661 }); 662 } 663 664 private inputMethodAbility_test_036(): void { 665 console.debug(TAG + '====>receive inputMethodAbility_test_036 data'); 666 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 667 inputMethodAbility.off('inputStart'); 668 let commonEventPublishData; 669 if (InputClient == null) { 670 commonEventPublishData = { 671 data: "FAILED" 672 }; 673 commoneventmanager.publish("inputMethodAbility_test_036", commonEventPublishData, this.publishCallback); 674 } else { 675 InputClient.getForward(1, (err, value) => { 676 if (err) { 677 console.debug(TAG + '====>inputMethodAbility_test_036 getForward err:' + JSON.stringify(err)); 678 commonEventPublishData = { 679 data: "FAILED" 680 }; 681 } else { 682 console.debug(TAG + '====>inputMethodAbility_test_036 getForward value:' + JSON.stringify(value)); 683 if (value) { 684 commonEventPublishData = { 685 data: "SUCCESS" 686 }; 687 } else { 688 commonEventPublishData = { 689 data: "FAILED" 690 }; 691 } 692 } 693 commoneventmanager.publish("inputMethodAbility_test_036", commonEventPublishData, this.publishCallback); 694 }); 695 } 696 }); 697 } 698 699 private inputMethodAbility_test_037(): void { 700 console.debug(TAG + '====>receive inputMethodAbility_test_037 data'); 701 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 702 inputMethodAbility.off('inputStart'); 703 let commonEventPublishData; 704 if (InputClient == null) { 705 commonEventPublishData = { 706 data: "FAILED" 707 }; 708 commoneventmanager.publish("inputMethodAbility_test_037", commonEventPublishData, this.publishCallback); 709 } else { 710 let value = await InputClient.getForward(1); 711 console.debug(TAG + '====>inputMethodAbility_test_037 getForward value' + JSON.stringify(value)); 712 if (value) { 713 commonEventPublishData = { 714 data: "SUCCESS" 715 }; 716 } else { 717 commonEventPublishData = { 718 data: "FAILED" 719 }; 720 } 721 commoneventmanager.publish("inputMethodAbility_test_037", commonEventPublishData, this.publishCallback); 722 } 723 }); 724 } 725 726 private inputMethodAbility_test_038(): void { 727 console.debug(TAG + '====>receive inputMethodAbility_test_038 data'); 728 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 729 inputMethodAbility.off('inputStart'); 730 let commonEventPublishData; 731 if (InputClient == null) { 732 commonEventPublishData = { 733 data: "FAILED" 734 }; 735 commoneventmanager.publish("inputMethodAbility_test_038", commonEventPublishData, this.publishCallback); 736 } else { 737 InputClient.getEditorAttribute((err, value) => { 738 if (err) { 739 console.debug(TAG + '====>inputMethodAbility_test_038 getEditorAttribute err:' + JSON.stringify(err)); 740 commonEventPublishData = { 741 data: "FAILED" 742 }; 743 } else { 744 console.debug(TAG + '====>inputMethodAbility_test_038 getEditorAttribute value:' + JSON.stringify(value)); 745 if (value) { 746 commonEventPublishData = { 747 data: "SUCCESS" 748 }; 749 } else { 750 commonEventPublishData = { 751 data: "FAILED" 752 }; 753 } 754 } 755 commoneventmanager.publish("inputMethodAbility_test_038", commonEventPublishData, this.publishCallback); 756 }); 757 } 758 }); 759 } 760 761 private inputMethodAbility_test_039(): void { 762 console.debug(TAG + '====>receive inputMethodAbility_test_039 data'); 763 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 764 inputMethodAbility.off('inputStart'); 765 let commonEventPublishData; 766 if (InputClient == null) { 767 commonEventPublishData = { 768 data: "FAILED" 769 }; 770 commoneventmanager.publish("inputMethodAbility_test_039", commonEventPublishData, this.publishCallback); 771 } else { 772 let value = await InputClient.getEditorAttribute(); 773 console.debug(TAG + '====>inputMethodAbility_test_039 getEditorAttribute value:' + JSON.stringify(value)); 774 if (value) { 775 commonEventPublishData = { 776 data: "SUCCESS" 777 }; 778 } else { 779 commonEventPublishData = { 780 data: "FAILED" 781 }; 782 } 783 commoneventmanager.publish("inputMethodAbility_test_039", commonEventPublishData, this.publishCallback); 784 } 785 }); 786 } 787 788 private inputMethodAbility_test_040(): void { 789 console.debug(TAG + '====>receive inputMethodAbility_test_040 data'); 790 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 791 inputMethodAbility.off('inputStart'); 792 let commonEventPublishData; 793 if (InputClient == null) { 794 commonEventPublishData = { 795 data: "FAILED" 796 }; 797 commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback); 798 } else { 799 try { 800 KeyboardDelegate.hideKeyboard((err, value) => { 801 if (err) { 802 console.debug(TAG + '====>inputMethodAbility_test_040 hideKeyboard err:' + JSON.stringify(err)); 803 commonEventPublishData = { 804 data: "FAILED" 805 }; 806 } else { 807 commonEventPublishData = { 808 data: "SUCCESS" 809 }; 810 } 811 commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback); 812 }); 813 } catch (err) { 814 commonEventPublishData = { 815 data: "FAILED" 816 }; 817 console.debug(TAG + '====>inputMethodAbility_test_040 hideKeyboard throw_err:'); 818 commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback); 819 } 820 } 821 }); 822 } 823 824 private inputMethodAbility_test_041(): void { 825 console.debug(TAG + '====>receive inputMethodAbility_test_041 data'); 826 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 827 inputMethodAbility.off('inputStart'); 828 let commonEventPublishData; 829 if (InputClient == null) { 830 commonEventPublishData = { 831 data: "FAILED" 832 }; 833 commoneventmanager.publish("inputMethodAbility_test_041", commonEventPublishData, this.publishCallback); 834 } else { 835 try { 836 await KeyboardDelegate.hideKeyboard(); 837 console.debug(TAG + '====>inputMethodAbility_test_041 hideKeyboard success'); 838 commonEventPublishData = { 839 data: "SUCCESS" 840 }; 841 } catch (err) { 842 commonEventPublishData = { 843 data: "FAILED" 844 }; 845 console.debug(TAG + '====>inputMethodAbility_test_041 hideKeyboard catch err:' + JSON.stringify(err)); 846 } 847 commoneventmanager.publish("inputMethodAbility_test_041", commonEventPublishData, this.publishCallback); 848 } 849 }); 850 } 851 852 private inputMethodAbility_test_042(): void { 853 console.debug(TAG + '====>receive inputMethodAbility_test_042 data'); 854 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 855 inputMethodAbility.off('inputStart'); 856 let commonEventPublishData; 857 if (InputClient == null) { 858 commonEventPublishData = { 859 data: "FAILED" 860 }; 861 commoneventmanager.publish("inputMethodAbility_test_042", commonEventPublishData, this.publishCallback); 862 } else { 863 InputClient.getBackward(1, (err, value) => { 864 if (err) { 865 console.debug(TAG + '====>inputMethodAbility_test_042 getBackward err:' + JSON.stringify(err)); 866 commonEventPublishData = { 867 data: "FAILED" 868 }; 869 } else { 870 console.debug(TAG + '====>inputMethodAbility_test_042 getBackward value:' + JSON.stringify(value)); 871 commonEventPublishData = { 872 data: "SUCCESS" 873 }; 874 } 875 commoneventmanager.publish("inputMethodAbility_test_042", commonEventPublishData, this.publishCallback); 876 }); 877 } 878 }); 879 } 880 881 private inputMethodAbility_test_043(): void { 882 console.debug(TAG + '====>receive inputMethodAbility_test_043 data'); 883 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 884 inputMethodAbility.off('inputStart'); 885 let commonEventPublishData; 886 if (InputClient == null) { 887 commonEventPublishData = { 888 data: "FAILED" 889 }; 890 commoneventmanager.publish("inputMethodAbility_test_043", commonEventPublishData, this.publishCallback); 891 } else { 892 let value = await InputClient.getBackward(1); 893 console.debug(TAG + '====>inputMethodAbility_test_043 getBackward value:' + JSON.stringify(value)); 894 commonEventPublishData = { 895 data: "SUCCESS" 896 }; 897 commoneventmanager.publish("inputMethodAbility_test_043", commonEventPublishData, this.publishCallback); 898 } 899 }); 900 } 901 902 private inputMethodAbility_test_045(): void { 903 console.debug(TAG + '====>receive inputMethodAbility_test_045 data'); 904 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 905 inputMethodAbility.off('inputStart'); 906 let t = setTimeout(()=>{ 907 let commonEventPublishData; 908 if (InputClient == null) { 909 commonEventPublishData = { 910 data: "FAILED" 911 }; 912 commoneventmanager.publish("inputMethodAbility_test_045", commonEventPublishData, this.publishCallback); 913 } else { 914 InputClient.moveCursor(inputMethodEngine.CURSOR_UP, (err, value) => { 915 if (err) { 916 console.debug(TAG + '====>inputMethodAbility_test_045 CURSOR_UP err:' + JSON.stringify(err)); 917 commonEventPublishData = { 918 data: "FAILED" 919 }; 920 } else { 921 console.debug(TAG + '====>inputMethodAbility_test_045 CURSOR_UP value:' + JSON.stringify(value)); 922 commonEventPublishData = { 923 data: "SUCCESS" 924 }; 925 } 926 commoneventmanager.publish("inputMethodAbility_test_045", commonEventPublishData, this.publishCallback); 927 }); 928 } 929 clearTimeout(t); 930 },1000); 931 932 }); 933 } 934 935 private inputMethodAbility_test_046(): void { 936 console.debug(TAG + '====>receive inputMethodAbility_test_046 data'); 937 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 938 inputMethodAbility.off('inputStart'); 939 let commonEventPublishData; 940 if (InputClient == null) { 941 commonEventPublishData = { 942 data: "FAILED" 943 }; 944 commoneventmanager.publish("inputMethodAbility_test_046", commonEventPublishData, this.publishCallback); 945 } else { 946 InputClient.moveCursor(inputMethodEngine.CURSOR_DOWN, (err, value) => { 947 if (err) { 948 console.debug(TAG + '====>inputMethodAbility_test_046 CURSOR_DOWN err:' + JSON.stringify(err)); 949 commonEventPublishData = { 950 data: "FAILED" 951 }; 952 } else { 953 console.debug(TAG + '====>inputMethodAbility_test_046 CURSOR_DOWN value:' + JSON.stringify(value)); 954 commonEventPublishData = { 955 data: "SUCCESS" 956 }; 957 } 958 commoneventmanager.publish("inputMethodAbility_test_046", commonEventPublishData, this.publishCallback); 959 }); 960 } 961 }); 962 } 963 964 private inputMethodAbility_test_047(): void { 965 console.debug(TAG + '====>receive inputMethodAbility_test_047 data'); 966 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 967 inputMethodAbility.off('inputStart'); 968 let commonEventPublishData; 969 if (InputClient == null) { 970 commonEventPublishData = { 971 data: "FAILED" 972 }; 973 commoneventmanager.publish("inputMethodAbility_test_047", commonEventPublishData, this.publishCallback); 974 } else { 975 await InputClient.moveCursor(inputMethodEngine.CURSOR_LEFT); 976 console.debug(TAG + '====>inputMethodAbility_test_047 CURSOR_LEFT success'); 977 commonEventPublishData = { 978 data: "SUCCESS" 979 }; 980 commoneventmanager.publish("inputMethodAbility_test_047", commonEventPublishData, this.publishCallback); 981 } 982 }); 983 } 984 985 private inputMethodAbility_test_048(): void { 986 console.debug(TAG + '====>receive inputMethodAbility_test_048 data'); 987 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 988 inputMethodAbility.off('inputStart'); 989 let commonEventPublishData; 990 if (InputClient == null) { 991 commonEventPublishData = { 992 data: "FAILED" 993 }; 994 commoneventmanager.publish("inputMethodAbility_test_048", commonEventPublishData, this.publishCallback); 995 } else { 996 await InputClient.moveCursor(inputMethodEngine.CURSOR_RIGHT); 997 console.debug(TAG + '====>inputMethodAbility_test_048 CURSOR_RIGHT success'); 998 commonEventPublishData = { 999 data: "SUCCESS" 1000 }; 1001 commoneventmanager.publish("inputMethodAbility_test_048", commonEventPublishData, this.publishCallback); 1002 } 1003 }); 1004 } 1005 1006 private inputMethodAbility_test_049(): void { 1007 console.debug(TAG + '====>receive inputMethodAbility_test_049 data'); 1008 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1009 inputMethodAbility.off('inputStart'); 1010 let commonEventPublishData; 1011 if (InputClient == null) { 1012 commonEventPublishData = { 1013 data: "FAILED" 1014 }; 1015 commoneventmanager.publish("inputMethodAbility_test_049", commonEventPublishData, this.publishCallback); 1016 } else { 1017 try { 1018 KeyboardDelegate.hide((err, value) => { 1019 if (err) { 1020 console.debug(TAG + '====>inputMethodAbility_test_049 hide err:' + JSON.stringify(err)); 1021 commonEventPublishData = { 1022 data: "FAILED" 1023 }; 1024 } else { 1025 commonEventPublishData = { 1026 data: "SUCCESS" 1027 }; 1028 } 1029 commoneventmanager.publish("inputMethodAbility_test_049", commonEventPublishData, this.publishCallback); 1030 }); 1031 } catch (err) { 1032 commonEventPublishData = { 1033 data: "FAILED" 1034 }; 1035 console.debug(TAG + '====>inputMethodAbility_test_049 hide throw_err:'); 1036 commoneventmanager.publish("inputMethodAbility_test_040", commonEventPublishData, this.publishCallback); 1037 } 1038 } 1039 }); 1040 } 1041 1042 private inputMethodAbility_test_050(): void { 1043 console.debug(TAG + '====>receive inputMethodAbility_test_050 data'); 1044 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1045 inputMethodAbility.off('inputStart'); 1046 let commonEventPublishData; 1047 if (InputClient == null) { 1048 commonEventPublishData = { 1049 data: "FAILED" 1050 }; 1051 commoneventmanager.publish("inputMethodAbility_test_050", commonEventPublishData, this.publishCallback); 1052 } else { 1053 try { 1054 await KeyboardDelegate.hide(); 1055 console.debug(TAG + '====>inputMethodAbility_test_050 hideKeyboard success'); 1056 commonEventPublishData = { 1057 data: "SUCCESS" 1058 }; 1059 } catch (err) { 1060 commonEventPublishData = { 1061 data: "FAILED" 1062 }; 1063 console.debug(TAG + '====>inputMethodAbility_test_050 hideKeyboard catch err:' + JSON.stringify(err)); 1064 } 1065 commoneventmanager.publish("inputMethodAbility_test_050", commonEventPublishData, this.publishCallback); 1066 } 1067 }); 1068 } 1069 1070 private inputMethodAbility_test_070(): void{ 1071 let commonEventPublishData = { 1072 data: "FAILED" 1073 }; 1074 console.info(TAG + '====>receive inputMethodAbility_test_070 success'); 1075 let count = 0; 1076 inputMethodAbility.on('inputStart', (KeyboardDelegate, InputClient) => { 1077 inputMethodAbility.off('inputStart'); 1078 console.info(TAG + '====>inputMethodAbility.on("inputStart") count: ' + count); 1079 count += 1; 1080 }); 1081 inputMethodAbility.on('keyboardShow', () => { 1082 inputMethodAbility.off('keyboardShow'); 1083 console.info(TAG + '====>inputMethodAbility.on("keyboardShow") count: ' + count); 1084 count += 1; 1085 }); 1086 inputMethodAbility.on('setSubtype', () => { 1087 inputMethodAbility.off('setSubtype'); 1088 console.info(TAG + '====>inputMethodAbility.on("setSubtype") count: ' + count); 1089 count += 1; 1090 }); 1091 1092 let t = setTimeout(() => { 1093 if(count === 2){ 1094 commonEventPublishData = { 1095 data: "SUCCESS" 1096 }; 1097 } 1098 commoneventmanager.publish("inputMethodAbility_test_070", commonEventPublishData, this.publishCallback); 1099 clearTimeout(t); 1100 },500); 1101 } 1102 1103 private inputMethodAbility_test_071(): void{ 1104 let commonEventPublishData = { 1105 data: "FAILED" 1106 }; 1107 console.info(TAG + '====>receive inputMethodAbility_test_071 success'); 1108 let count = 0; 1109 inputMethodAbility.on('keyboardHide', () => { 1110 count += 1; 1111 inputMethodAbility.off("keyboardHide"); 1112 console.info(TAG + '====>inputMethodAbility.off("keyboardHide") count: ' + count); 1113 }); 1114 inputMethodAbility.on('inputStart', (KeyboardDelegate, InputClient) => { 1115 console.info(TAG + '====>inputMethodAbility_test_071 inputMethodAbility.on("inputStart")'); 1116 let t = setInterval(async () => { 1117 await KeyboardDelegate.hideKeyboard(); 1118 console.info(TAG + '====>KeyboardDelegate.hideKeyboard count: ' + count); 1119 if(count === 1){ 1120 clearInterval(t); 1121 } 1122 },100); 1123 }); 1124 let t = setTimeout(() => { 1125 if(count === 1){ 1126 commonEventPublishData = { 1127 data: "SUCCESS" 1128 }; 1129 } 1130 commoneventmanager.publish("inputMethodAbility_test_071", commonEventPublishData, this.publishCallback); 1131 clearTimeout(t); 1132 },500); 1133 } 1134 1135 private inputMethodAbility_test_072(): void{ 1136 let commonEventPublishData = { 1137 data: "FAILED" 1138 }; 1139 console.info(TAG + '====>receive inputMethodAbility_test_072 success'); 1140 let count = 0; 1141 inputMethodAbility.on('keyboardShow', () => { 1142 count += 1; 1143 inputMethodAbility.off("keyboardShow"); 1144 console.info(TAG + '====>inputMethodAbility.off("keyboardShow") count: ' + count); 1145 }); 1146 let t = setTimeout(() => { 1147 if(count === 1){ 1148 commonEventPublishData = { 1149 data: "SUCCESS" 1150 }; 1151 } 1152 commoneventmanager.publish("inputMethodAbility_test_072", commonEventPublishData, this.publishCallback); 1153 clearTimeout(t); 1154 },300); 1155 } 1156 1157 private inputMethodAbility_test_073(): void{ 1158 let commonEventPublishData = { 1159 data: "FAILED" 1160 }; 1161 console.info(TAG + '====>receive inputMethodAbility_test_073 success'); 1162 let count = 0; 1163 inputKeyboardDelegate.on('keyDown', (keyEvent) => { 1164 inputKeyboardDelegate.off('keyDown'); 1165 console.info(TAG + "====>inputKeyboardDelegate.on('keyDown') count: " + count); 1166 if (keyEvent.keyCode === 2000){ 1167 count += 1; 1168 } 1169 return true; 1170 }); 1171 1172 inputKeyboardDelegate.on('keyUp', (keyEvent) => { 1173 inputKeyboardDelegate.off('keyUp'); 1174 console.info(TAG + "====>inputKeyboardDelegate.on('keyUp') count: " + count); 1175 if (keyEvent.keyCode === 2000){ 1176 count += 1; 1177 } 1178 console.info(TAG + "====>inputKeyboardDelegate.on('keyUp') count: " + count); 1179 return true; 1180 }); 1181 let t = setTimeout(() => { 1182 if(count === 2){ 1183 commonEventPublishData = { 1184 data: "SUCCESS" 1185 }; 1186 } 1187 commoneventmanager.publish("inputMethodAbility_test_073", commonEventPublishData, this.publishCallback); 1188 clearTimeout(t); 1189 },500); 1190 } 1191 1192 private inputMethodAbility_test_074(): void{ 1193 let commonEventPublishData = { 1194 data: "FAILED" 1195 }; 1196 console.info(TAG + '====>receive inputMethodAbility_test_074 success'); 1197 inputMethodAbility.on('setCallingWindow', (wid) => { 1198 console.info(TAG + "====>inputKeyboardDelegate.on('setCallingWindow')" + wid); 1199 inputMethodAbility.off('setCallingWindow', () => { 1200 console.log('inputMethodAbility off setCallingWindow' ); 1201 }); 1202 if (typeof(wid) === "number"){ 1203 commonEventPublishData = { 1204 data: "SUCCESS" 1205 }; 1206 } 1207 commoneventmanager.publish("inputMethodAbility_test_074", commonEventPublishData, this.publishCallback); 1208 }); 1209 } 1210 1211 private inputMethodAbility_test_101(): void { 1212 console.debug(TAG + '====>receive inputMethodAbility_test_101 data'); 1213 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1214 inputMethodAbility.off('inputStart'); 1215 let commonEventPublishData; 1216 let range = { start: 0, end: 1 }; 1217 if (InputClient == null) { 1218 commonEventPublishData = { 1219 data: "FAILED" 1220 }; 1221 commoneventmanager.publish("inputMethodAbility_test_101", commonEventPublishData, this.publishCallback); 1222 } else { 1223 try { 1224 InputClient.selectByRange(range, (err, value) => { 1225 if (err) { 1226 console.debug(TAG + '====>inputMethodAbility_test_101 selectByRange err:' + JSON.stringify(err)); 1227 commonEventPublishData = { 1228 data: "FAILED" 1229 }; 1230 } else { 1231 commonEventPublishData = { 1232 data: "SUCCESS" 1233 }; 1234 } 1235 commoneventmanager.publish("inputMethodAbility_test_101", commonEventPublishData, this.publishCallback); 1236 }); 1237 } catch (err) { 1238 commonEventPublishData = { 1239 data: "FAILED" 1240 }; 1241 console.debug(TAG + '====>inputMethodAbility_test_101 selectByRange throw_err:'); 1242 commoneventmanager.publish("inputMethodAbility_test_101", commonEventPublishData, this.publishCallback); 1243 } 1244 } 1245 }); 1246 } 1247 1248 private inputMethodAbility_test_102(): void { 1249 console.debug(TAG + '====>receive inputMethodAbility_test_102 data'); 1250 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1251 inputMethodAbility.off('inputStart'); 1252 let commonEventPublishData; 1253 let range = { start: 1, end: 0 }; 1254 if (InputClient == null) { 1255 commonEventPublishData = { 1256 data: "FAILED" 1257 }; 1258 commoneventmanager.publish("inputMethodAbility_test_102", commonEventPublishData, this.publishCallback); 1259 } else { 1260 try { 1261 await InputClient.selectByRange(range); 1262 console.debug(TAG + '====>inputMethodAbility_test_102 selectByRange success'); 1263 commonEventPublishData = { 1264 data: "SUCCESS" 1265 }; 1266 } catch (err) { 1267 commonEventPublishData = { 1268 data: "FAILED" 1269 }; 1270 console.debug(TAG + '====>inputMethodAbility_test_102 selectByRange catch err:' + JSON.stringify(err)); 1271 } 1272 commoneventmanager.publish("inputMethodAbility_test_102", commonEventPublishData, this.publishCallback); 1273 } 1274 }); 1275 } 1276 1277 private inputMethodAbility_test_103(): void { 1278 console.debug(TAG + '====>receive inputMethodAbility_test_103 data'); 1279 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1280 inputMethodAbility.off('inputStart'); 1281 let commonEventPublishData; 1282 if (InputClient == null) { 1283 commonEventPublishData = { 1284 data: "FAILED" 1285 }; 1286 commoneventmanager.publish("inputMethodAbility_test_103", commonEventPublishData, this.publishCallback); 1287 } else { 1288 try { 1289 InputClient.getTextIndexAtCursor((err, value) => { 1290 if (err) { 1291 console.debug(TAG + '====>inputMethodAbility_test_103 getTextIndexAtCursor err:' + JSON.stringify(err)); 1292 commonEventPublishData = { 1293 data: "FAILED" 1294 }; 1295 } else { 1296 console.debug(TAG + '====>inputMethodAbility_test_103 getTextIndexAtCursor success' + JSON.stringify(value)); 1297 if (typeof value === 'number') { 1298 commonEventPublishData = { 1299 data: "SUCCESS" 1300 }; 1301 } else { 1302 commonEventPublishData = { 1303 data: "FAILED" 1304 }; 1305 } 1306 } 1307 commoneventmanager.publish("inputMethodAbility_test_103", commonEventPublishData, this.publishCallback); 1308 }); 1309 } catch (err) { 1310 commonEventPublishData = { 1311 data: "FAILED" 1312 }; 1313 console.debug(TAG + '====>inputMethodAbility_test_103 getTextIndexAtCursor throw_err:'); 1314 commoneventmanager.publish("inputMethodAbility_test_103", commonEventPublishData, this.publishCallback); 1315 } 1316 } 1317 }); 1318 } 1319 1320 private inputMethodAbility_test_104(): void { 1321 console.debug(TAG + '====>receive inputMethodAbility_test_104 data'); 1322 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1323 inputMethodAbility.off('inputStart'); 1324 let commonEventPublishData; 1325 if (InputClient == null) { 1326 commonEventPublishData = { 1327 data: "FAILED" 1328 }; 1329 commoneventmanager.publish("inputMethodAbility_test_104", commonEventPublishData, this.publishCallback); 1330 } else { 1331 try { 1332 let value = await InputClient.getTextIndexAtCursor(); 1333 console.debug(TAG + '====>inputMethodAbility_test_104 getTextIndexAtCursor value:' + JSON.stringify(value)); 1334 if (typeof value === 'number') { 1335 commonEventPublishData = { 1336 data: "SUCCESS" 1337 }; 1338 } else { 1339 commonEventPublishData = { 1340 data: "FAILED" 1341 }; 1342 } 1343 } catch (err) { 1344 commonEventPublishData = { 1345 data: "FAILED" 1346 }; 1347 console.debug(TAG + '====>inputMethodAbility_test_104 getTextIndexAtCursor catch err:'); 1348 } 1349 commoneventmanager.publish("inputMethodAbility_test_104", commonEventPublishData, this.publishCallback); 1350 } 1351 }); 1352 } 1353 1354 private inputMethodAbility_test_105(): void { 1355 console.debug(TAG + '====>receive inputMethodAbility_test_105 data'); 1356 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1357 inputMethodAbility.off('inputStart'); 1358 let commonEventPublishData; 1359 let movement = { direction: inputMethodEngine.CURSOR_DOWN }; 1360 if (InputClient == null) { 1361 commonEventPublishData = { 1362 data: "FAILED" 1363 }; 1364 commoneventmanager.publish("inputMethodAbility_test_105", commonEventPublishData, this.publishCallback); 1365 } else { 1366 try { 1367 InputClient.selectByMovement(movement, (err, value) => { 1368 if (err) { 1369 console.debug(TAG + '====>inputMethodAbility_test_105 selectByMovement err:' + JSON.stringify(err)); 1370 commonEventPublishData = { 1371 data: "FAILED" 1372 }; 1373 } else { 1374 console.debug(TAG + '====>inputMethodAbility_test_105 selectByMovement success'); 1375 commonEventPublishData = { 1376 data: "SUCCESS" 1377 }; 1378 } 1379 commoneventmanager.publish("inputMethodAbility_test_105", commonEventPublishData, this.publishCallback); 1380 }); 1381 } catch (err) { 1382 commonEventPublishData = { 1383 data: "FAILED" 1384 }; 1385 console.debug(TAG + '====>inputMethodAbility_test_105 selectByMovement throw_err:'); 1386 commoneventmanager.publish("inputMethodAbility_test_105", commonEventPublishData, this.publishCallback); 1387 } 1388 } 1389 }); 1390 } 1391 1392 private inputMethodAbility_test_106(): void { 1393 console.debug(TAG + '====>receive inputMethodAbility_test_106 data'); 1394 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1395 inputMethodAbility.off('inputStart'); 1396 let commonEventPublishData; 1397 let movement = { direction: inputMethodEngine.CURSOR_RIGHT }; 1398 if (InputClient == null) { 1399 commonEventPublishData = { 1400 data: "FAILED" 1401 }; 1402 commoneventmanager.publish("inputMethodAbility_test_106", commonEventPublishData, this.publishCallback); 1403 } else { 1404 try { 1405 let value = await InputClient.selectByMovement(movement); 1406 console.debug(TAG + '====>inputMethodAbility_test_106 selectByMovement success'); 1407 commonEventPublishData = { 1408 data: "SUCCESS" 1409 }; 1410 } catch (err) { 1411 commonEventPublishData = { 1412 data: "FAILED" 1413 }; 1414 console.debug(TAG + '====>inputMethodAbility_test_106 getTextIndexAtCursor catch err:'); 1415 } 1416 commoneventmanager.publish("inputMethodAbility_test_106", commonEventPublishData, this.publishCallback); 1417 } 1418 }); 1419 } 1420 1421 private Sub_Misc_inputMethod_onSelectByRange_0110(): void { 1422 let commonEventPublishData; 1423 console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByRange_0110 success'); 1424 try{ 1425 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1426 console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByRange_0110 success inputStart'); 1427 let commonEventPublishData; 1428 let range = { start: 0, end: 10 }; 1429 inputMethodAbility.off('inputStart'); 1430 1431 if (InputClient == null) { 1432 commonEventPublishData = { 1433 data: "FAILED" 1434 }; 1435 commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByRange_0110", commonEventPublishData, this.publishCallback); 1436 } else { 1437 commonEventPublishData = { 1438 data: "SUCCESS" 1439 }; 1440 try { 1441 console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 selectByRange success'); 1442 commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByRange_0110", commonEventPublishData, this.publishCallback); 1443 await InputClient.selectByRange(range); 1444 } catch (err) { 1445 console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByRange_0110 selectByRange catch err:' + JSON.stringify(err)); 1446 commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByRange_0110", commonEventPublishData, this.publishCallback); 1447 1448 } 1449 } 1450 }); 1451 }catch(error){ 1452 commonEventPublishData = { 1453 data: "FAILED" 1454 }; 1455 console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByRange_0110 catch error: ' + JSON.stringify(error)); 1456 commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByRange_0110", commonEventPublishData, this.publishCallback); 1457 } 1458 } 1459 1460 private Sub_Misc_inputMethod_onSelectByMovement_0120(): void { 1461 let commonEventPublishData; 1462 console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByMovement_0120 success'); 1463 try{ 1464 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1465 console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByMovement_0120 success inputStart'); 1466 let commonEventPublishData; 1467 let movement = { direction: inputMethodEngine.CURSOR_DOWN }; 1468 inputMethodAbility.off('inputStart'); 1469 1470 if (InputClient == null) { 1471 commonEventPublishData = { 1472 data: "FAILED" 1473 }; 1474 commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByMovement_0120", commonEventPublishData, this.publishCallback); 1475 } else { 1476 commonEventPublishData = { 1477 data: "SUCCESS" 1478 }; 1479 try { 1480 console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 onSelectByMovement success'); 1481 commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByMovement_0120", commonEventPublishData, this.publishCallback); 1482 await InputClient.selectByMovement(movement); 1483 } catch (err) { 1484 console.debug(TAG + '====>Sub_Misc_inputMethod_onSelectByMovement_0120 onSelectByMovement catch err:' + JSON.stringify(err)); 1485 commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByMovement_0120", commonEventPublishData, this.publishCallback); 1486 1487 } 1488 } 1489 }); 1490 }catch(error){ 1491 commonEventPublishData = { 1492 data: "FAILED" 1493 }; 1494 console.info(TAG + '====>receive Sub_Misc_inputMethod_onSelectByMovement_0120 catch error: ' + JSON.stringify(error)); 1495 commoneventmanager.publish("Sub_Misc_inputMethod_onSelectByMovement_0120", commonEventPublishData, this.publishCallback); 1496 } 1497 } 1498 1499 private Sub_Misc_inputMethod_offSelectByRange_0130(): void { 1500 let commonEventPublishData; 1501 console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByRange_0130 success'); 1502 try{ 1503 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1504 console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByRange_0130 success inputStart'); 1505 let commonEventPublishData; 1506 let timeCount = 0; 1507 let range = { start: 0, end: 10 }; 1508 inputMethodAbility.off('inputStart'); 1509 1510 if (InputClient == null) { 1511 commonEventPublishData = { 1512 data: "FAILED" 1513 }; 1514 commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByRange_0130", commonEventPublishData, this.publishCallback); 1515 } else { 1516 commonEventPublishData = { 1517 data: "SUCCESS" 1518 }; 1519 try { 1520 console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByRange_0130 offSelectByRange in'); 1521 commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByRange_0130", commonEventPublishData, this.publishCallback); 1522 let t1 = setInterval(async () => {; 1523 await InputClient.selectByRange(range); 1524 timeCount += 1; 1525 console.info(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 this.softKeyboardPanel.hide setInterval timeCount: ' + timeCount); 1526 if(timeCount === 2){ 1527 clearInterval(t1); 1528 } 1529 },100); 1530 } catch (err) { 1531 console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByRange_0130 offSelectByRange catch err:' + JSON.stringify(err)); 1532 commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByRange_0130", commonEventPublishData, this.publishCallback); 1533 1534 } 1535 } 1536 }); 1537 }catch(error){ 1538 commonEventPublishData = { 1539 data: "FAILED" 1540 }; 1541 console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByRange_0130 catch error: ' + JSON.stringify(error)); 1542 commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByRange_0130", commonEventPublishData, this.publishCallback); 1543 } 1544 } 1545 1546 private Sub_Misc_inputMethod_offSelectByMovement_0140(): void { 1547 let commonEventPublishData; 1548 console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByMovement_0140 success'); 1549 try{ 1550 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1551 console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByMovement_0140 success inputStart'); 1552 let commonEventPublishData; 1553 let timeCount = 0; 1554 let movement = { direction: inputMethodEngine.CURSOR_DOWN }; 1555 inputMethodAbility.off('inputStart'); 1556 1557 if (InputClient == null) { 1558 commonEventPublishData = { 1559 data: "FAILED" 1560 }; 1561 commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByMovement_0140", commonEventPublishData, this.publishCallback); 1562 } else { 1563 commonEventPublishData = { 1564 data: "SUCCESS" 1565 }; 1566 try { 1567 console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 offSelectByMovement in'); 1568 commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByMovement_0140", commonEventPublishData, this.publishCallback); 1569 let t1 = setInterval(async () => {; 1570 await InputClient.selectByMovement(movement); 1571 timeCount += 1; 1572 console.info(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 this.softKeyboardPanel.hide setInterval timeCount: ' + timeCount); 1573 if(timeCount === 2){ 1574 clearInterval(t1); 1575 } 1576 },100); 1577 } catch (err) { 1578 console.debug(TAG + '====>Sub_Misc_inputMethod_offSelectByMovement_0140 offSelectByMovement catch err:' + JSON.stringify(err)); 1579 commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByMovement_0140", commonEventPublishData, this.publishCallback); 1580 1581 } 1582 } 1583 }); 1584 }catch(error){ 1585 commonEventPublishData = { 1586 data: "FAILED" 1587 }; 1588 console.info(TAG + '====>receive Sub_Misc_inputMethod_offSelectByMovement_0140 catch error: ' + JSON.stringify(error)); 1589 commoneventmanager.publish("Sub_Misc_inputMethod_offSelectByMovement_0140", commonEventPublishData, this.publishCallback); 1590 } 1591 } 1592 1593 private Sub_Misc_inputMethod_sendExtendAction_0170(): void{ 1594 console.debug(TAG + '====>receive Sub_Misc_inputMethod_sendExtendAction_0170 data'); 1595 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1596 inputMethodAbility.off('inputStart'); 1597 let commonEventPublishData; 1598 if (InputClient == null) { 1599 commonEventPublishData = { 1600 data: "FAILED" 1601 }; 1602 commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0170", commonEventPublishData, this.publishCallback); 1603 } else { 1604 try { 1605 InputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY, (err,) => { 1606 if (err) { 1607 console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 sendExtendAction err:' + JSON.stringify(err)); 1608 commonEventPublishData = { 1609 data: "FAILED" 1610 }; 1611 } else { 1612 console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 sendExtendAction success' ); 1613 commonEventPublishData = { 1614 data: "SUCCESS" 1615 }; 1616 } 1617 commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0170", commonEventPublishData, this.publishCallback); 1618 }); 1619 } catch (err) { 1620 commonEventPublishData = { 1621 data: "FAILED" 1622 }; 1623 console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0170 getTextIndexAtCursor throw_err:'); 1624 commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0170", commonEventPublishData, this.publishCallback); 1625 } 1626 } 1627 }); 1628 } 1629 1630 private Sub_Misc_inputMethod_sendExtendAction_0180(): void{ 1631 console.debug(TAG + '====>receive Sub_Misc_inputMethod_sendExtendAction_0180 data'); 1632 inputMethodAbility.on('inputStart', async (KeyboardDelegate, InputClient) => { 1633 inputMethodAbility.off('inputStart'); 1634 let commonEventPublishData; 1635 if (InputClient == null) { 1636 commonEventPublishData = { 1637 data: "FAILED" 1638 }; 1639 commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0180", commonEventPublishData, this.publishCallback); 1640 } else { 1641 try { 1642 await InputClient.sendExtendAction(inputMethodEngine.ExtendAction.COPY); 1643 console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 sendExtendAction success:'); 1644 commonEventPublishData = { 1645 data: "SUCCESS" 1646 }; 1647 } catch (err) { 1648 commonEventPublishData = { 1649 data: "FAILED" 1650 }; 1651 console.debug(TAG + '====>Sub_Misc_inputMethod_sendExtendAction_0180 sendExtendAction catch err:'); 1652 } 1653 commoneventmanager.publish("Sub_Misc_inputMethod_sendExtendAction_0180", commonEventPublishData, this.publishCallback); 1654 } 1655 }); 1656 } 1657 1658 private Sub_Misc_inputMethod_getForward_sync_0200(): void{ 1659 console.info(TAG + '====>receive Sub_Misc_inputMethod_getForward_sync_0200 data'); 1660 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1661 inputMethodAbility.off('inputStart'); 1662 let commonEventPublishData = { 1663 data: "FAILED" 1664 }; 1665 if (InputClient == null) { 1666 commoneventmanager.publish("Sub_Misc_inputMethod_getForward_sync_0200", commonEventPublishData, this.publishCallback); 1667 } else { 1668 let str = InputClient.getForwardSync(1); 1669 console.info(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0200 getForwardSync str: ' + JSON.stringify(str)); 1670 if(typeof(str) === "string"){ 1671 commonEventPublishData = { 1672 data: "SUCCESS" 1673 }; 1674 } 1675 commoneventmanager.publish("Sub_Misc_inputMethod_getForward_sync_0200", commonEventPublishData, this.publishCallback); 1676 } 1677 }); 1678 } 1679 1680 private Sub_Misc_inputMethod_getForward_sync_0201(): void{ 1681 console.info(TAG + '====>receive Sub_Misc_inputMethod_getForward_sync_0201 data'); 1682 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1683 inputMethodAbility.off('inputStart'); 1684 let commonEventPublishData = { 1685 data: "FAILED" 1686 }; 1687 if (InputClient == null) { 1688 commoneventmanager.publish("Sub_Misc_inputMethod_getForward_sync_0201", commonEventPublishData, this.publishCallback); 1689 } else { 1690 try { 1691 // @ts-ignore 1692 InputClient.getForwardSync("1"); 1693 console.info(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0201 getForwardSync over'); 1694 } catch (err) { 1695 console.info(TAG + '====>Sub_Misc_inputMethod_getForward_sync_0201 getForwardSync err: ' + JSON.stringify(err)); 1696 if(err.code === 401){ 1697 commonEventPublishData = { 1698 data: "SUCCESS" 1699 }; 1700 } 1701 } 1702 commoneventmanager.publish("Sub_Misc_inputMethod_getForward_sync_0201", commonEventPublishData, this.publishCallback); 1703 } 1704 }); 1705 } 1706 1707 private Sub_Misc_inputMethod_getBackward_sync_0210(): void{ 1708 console.info(TAG + '====>receive Sub_Misc_inputMethod_getBackward_sync_0210 data'); 1709 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1710 inputMethodAbility.off('inputStart'); 1711 let commonEventPublishData = { 1712 data: "FAILED" 1713 }; 1714 if (InputClient == null) { 1715 commoneventmanager.publish("Sub_Misc_inputMethod_getBackward_sync_0210", commonEventPublishData, this.publishCallback); 1716 } else { 1717 let str = InputClient.getBackwardSync(1); 1718 console.info(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0210 getBackwardSync str: ' + JSON.stringify(str)); 1719 if(typeof(str) === "string"){ 1720 commonEventPublishData = { 1721 data: "SUCCESS" 1722 }; 1723 } 1724 commoneventmanager.publish("Sub_Misc_inputMethod_getBackward_sync_0210", commonEventPublishData, this.publishCallback); 1725 } 1726 }); 1727 } 1728 1729 private Sub_Misc_inputMethod_getBackward_sync_0211(): void{ 1730 console.info(TAG + '====>receive Sub_Misc_inputMethod_getBackward_sync_0211 data'); 1731 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1732 inputMethodAbility.off('inputStart'); 1733 let commonEventPublishData = { 1734 data: "FAILED" 1735 }; 1736 if (InputClient == null) { 1737 commoneventmanager.publish("Sub_Misc_inputMethod_getBackward_sync_0211", commonEventPublishData, this.publishCallback); 1738 } else { 1739 try { 1740 // @ts-ignore 1741 InputClient.getBackwardSync("1"); 1742 console.info(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0211 getBackwardSync over'); 1743 } catch (err) { 1744 console.info(TAG + '====>Sub_Misc_inputMethod_getBackward_sync_0211 getBackwardSync err: ' + JSON.stringify(err)); 1745 if(err.code === 401){ 1746 commonEventPublishData = { 1747 data: "SUCCESS" 1748 }; 1749 } 1750 } 1751 commoneventmanager.publish("Sub_Misc_inputMethod_getBackward_sync_0211", commonEventPublishData, this.publishCallback); 1752 } 1753 }); 1754 } 1755 1756 private Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220(): void{ 1757 console.info(TAG + '====>receive Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220 data'); 1758 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1759 inputMethodAbility.off('inputStart'); 1760 let commonEventPublishData = { 1761 data: "FAILED" 1762 }; 1763 if (InputClient == null) { 1764 commoneventmanager.publish("Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220", commonEventPublishData, this.publishCallback); 1765 } else { 1766 let num = InputClient.getTextIndexAtCursorSync(); 1767 console.info(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220 getTextIndexAtCursorSync num: ' + JSON.stringify(num)); 1768 if(typeof(num) === "number"){ 1769 commonEventPublishData = { 1770 data: "SUCCESS" 1771 }; 1772 } 1773 commoneventmanager.publish("Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0220", commonEventPublishData, this.publishCallback); 1774 } 1775 }); 1776 } 1777 1778 private Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221(): void{ 1779 console.info(TAG + '====>receive Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221 data'); 1780 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1781 inputMethodAbility.off('inputStart'); 1782 let commonEventPublishData = { 1783 data: "FAILED" 1784 }; 1785 if (InputClient == null) { 1786 commoneventmanager.publish("Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221", commonEventPublishData, this.publishCallback); 1787 } else { 1788 try { 1789 // @ts-ignore 1790 InputClient.getTextIndexAtCursorSync("1"); 1791 console.info(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221 getTextIndexAtCursorSync success'); 1792 commonEventPublishData = { 1793 data: "SUCCESS" 1794 }; 1795 } catch (err) { 1796 console.info(TAG + '====>Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221 getTextIndexAtCursorSync err: ' + JSON.stringify(err)); 1797 } 1798 commoneventmanager.publish("Sub_Misc_inputMethod_getTextIndexAtCursor_sync_0221", commonEventPublishData, this.publishCallback); 1799 } 1800 }); 1801 } 1802 1803 private Sub_Misc_inputMethod_getEditorAttribute_sync_0230(): void{ 1804 console.debug(TAG + '====>receive Sub_Misc_inputMethod_getEditorAttribute_sync_0230 data'); 1805 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1806 inputMethodAbility.off('inputStart'); 1807 let commonEventPublishData = { 1808 data: "FAILED" 1809 }; 1810 if (InputClient == null) { 1811 commoneventmanager.publish("Sub_Misc_inputMethod_getEditorAttribute_sync_0230", commonEventPublishData, this.publishCallback); 1812 } else { 1813 let obj = InputClient.getEditorAttributeSync(); 1814 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0230 getEditorAttributeSync enterKeyType: ' + JSON.stringify(obj.enterKeyType)); 1815 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0230 getEditorAttributeSync inputPattern: ' + JSON.stringify(obj.inputPattern)); 1816 if(typeof(obj.enterKeyType) === "number" && typeof(obj.inputPattern) === "number"){ 1817 commonEventPublishData = { 1818 data: "SUCCESS" 1819 }; 1820 } 1821 commoneventmanager.publish("Sub_Misc_inputMethod_getEditorAttribute_sync_0230", commonEventPublishData, this.publishCallback); 1822 } 1823 }); 1824 } 1825 1826 private Sub_Misc_inputMethod_getEditorAttribute_sync_0231(): void{ 1827 console.info(TAG + '====>receive Sub_Misc_inputMethod_getEditorAttribute_sync_0231 data'); 1828 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1829 inputMethodAbility.off('inputStart'); 1830 let commonEventPublishData = { 1831 data: "FAILED" 1832 }; 1833 if (InputClient == null) { 1834 commoneventmanager.publish("Sub_Misc_inputMethod_getEditorAttribute_sync_0231", commonEventPublishData, this.publishCallback); 1835 } else { 1836 try { 1837 // @ts-ignore 1838 InputClient.getEditorAttributeSync(true); 1839 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0231 getEditorAttributeSync success'); 1840 commonEventPublishData = { 1841 data: "SUCCESS" 1842 }; 1843 } catch (err) { 1844 console.info(TAG + '====>Sub_Misc_inputMethod_getEditorAttribute_sync_0231 getEditorAttributeSync err: ' + JSON.stringify(err)); 1845 } 1846 commoneventmanager.publish("Sub_Misc_inputMethod_getEditorAttribute_sync_0231", commonEventPublishData, this.publishCallback); 1847 } 1848 }); 1849 } 1850 1851 private Sub_Misc_inputMethod_moveCursor_sync_0240(): void{ 1852 console.debug(TAG + '====>receive Sub_Misc_inputMethod_moveCursor_sync_0240 data'); 1853 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1854 inputMethodAbility.off('inputStart'); 1855 let commonEventPublishData = { 1856 data: "FAILED" 1857 }; 1858 if (InputClient == null) { 1859 commoneventmanager.publish("Sub_Misc_inputMethod_moveCursor_sync_0240", commonEventPublishData, this.publishCallback); 1860 } else { 1861 try { 1862 InputClient.moveCursorSync(inputMethodEngine.CURSOR_UP); 1863 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0240 moveCursorSync success' ); 1864 commonEventPublishData = { 1865 data: "SUCCESS" 1866 }; 1867 } catch (err) { 1868 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0240 moveCursorSync err: ' + JSON.stringify(err)); 1869 } 1870 commoneventmanager.publish("Sub_Misc_inputMethod_moveCursor_sync_0240", commonEventPublishData, this.publishCallback); 1871 } 1872 }); 1873 } 1874 1875 private Sub_Misc_inputMethod_moveCursor_sync_0241(): void{ 1876 console.info(TAG + '====>receive Sub_Misc_inputMethod_moveCursor_sync_0241 data'); 1877 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1878 inputMethodAbility.off('inputStart'); 1879 let commonEventPublishData = { 1880 data: "FAILED" 1881 }; 1882 if (InputClient == null) { 1883 commoneventmanager.publish("Sub_Misc_inputMethod_moveCursor_sync_0241", commonEventPublishData, this.publishCallback); 1884 } else { 1885 try { 1886 // @ts-ignore 1887 InputClient.moveCursorSync(true); 1888 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0241 moveCursorSync over'); 1889 } catch (err) { 1890 console.info(TAG + '====>Sub_Misc_inputMethod_moveCursor_sync_0241 moveCursorSync err: ' + JSON.stringify(err)); 1891 if(err.code === 401){ 1892 commonEventPublishData = { 1893 data: "SUCCESS" 1894 }; 1895 } 1896 } 1897 commoneventmanager.publish("Sub_Misc_inputMethod_moveCursor_sync_0241", commonEventPublishData, this.publishCallback); 1898 } 1899 }); 1900 } 1901 1902 private Sub_Misc_inputMethod_deleteForward_sync_0250(): void{ 1903 console.debug(TAG + '====>receive Sub_Misc_inputMethod_deleteForward_sync_0250 data'); 1904 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1905 inputMethodAbility.off('inputStart'); 1906 let commonEventPublishData = { 1907 data: "FAILED" 1908 }; 1909 if (InputClient == null) { 1910 commoneventmanager.publish("Sub_Misc_inputMethod_deleteForward_sync_0250", commonEventPublishData, this.publishCallback); 1911 } else { 1912 try { 1913 InputClient.deleteForwardSync(1); 1914 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0250 deleteForwardSync success'); 1915 commonEventPublishData = { 1916 data: "SUCCESS" 1917 }; 1918 } catch (err) { 1919 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0250 deleteForwardSync err: ' + JSON.stringify(err)); 1920 } 1921 commoneventmanager.publish("Sub_Misc_inputMethod_deleteForward_sync_0250", commonEventPublishData, this.publishCallback); 1922 } 1923 }); 1924 } 1925 1926 private Sub_Misc_inputMethod_deleteForward_sync_0251(): void{ 1927 console.info(TAG + '====>receive Sub_Misc_inputMethod_deleteForward_sync_0251 data'); 1928 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1929 inputMethodAbility.off('inputStart'); 1930 let commonEventPublishData = { 1931 data: "FAILED" 1932 }; 1933 if (InputClient == null) { 1934 commoneventmanager.publish("Sub_Misc_inputMethod_deleteForward_sync_0251", commonEventPublishData, this.publishCallback); 1935 } else { 1936 try { 1937 // @ts-ignore 1938 InputClient.deleteForwardSync(false); 1939 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0251 deleteForwardSync over'); 1940 } catch (err) { 1941 console.info(TAG + '====>Sub_Misc_inputMethod_deleteForward_sync_0251 deleteForwardSync err: ' + JSON.stringify(err)); 1942 if(err.code === 401){ 1943 commonEventPublishData = { 1944 data: "SUCCESS" 1945 }; 1946 } 1947 } 1948 commoneventmanager.publish("Sub_Misc_inputMethod_deleteForward_sync_0251", commonEventPublishData, this.publishCallback); 1949 } 1950 }); 1951 } 1952 1953 private Sub_Misc_inputMethod_deleteBackward_sync_0260(): void{ 1954 console.debug(TAG + '====>receive Sub_Misc_inputMethod_deleteBackward_sync_0260 data'); 1955 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1956 inputMethodAbility.off('inputStart'); 1957 let commonEventPublishData = { 1958 data: "FAILED" 1959 }; 1960 if (InputClient == null) { 1961 commoneventmanager.publish("Sub_Misc_inputMethod_deleteBackward_sync_0260", commonEventPublishData, this.publishCallback); 1962 } else { 1963 try { 1964 InputClient.deleteBackwardSync(1); 1965 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0260 deleteBackwardSync success'); 1966 commonEventPublishData = { 1967 data: "SUCCESS" 1968 }; 1969 } catch (err) { 1970 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0260 deleteBackwardSync err: ' + JSON.stringify(err)); 1971 } 1972 commoneventmanager.publish("Sub_Misc_inputMethod_deleteBackward_sync_0260", commonEventPublishData, this.publishCallback); 1973 } 1974 }); 1975 } 1976 1977 private Sub_Misc_inputMethod_deleteBackward_sync_0261(): void{ 1978 console.info(TAG + '====>receive Sub_Misc_inputMethod_deleteBackward_sync_0261 data'); 1979 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 1980 inputMethodAbility.off('inputStart'); 1981 let commonEventPublishData = { 1982 data: "FAILED" 1983 }; 1984 if (InputClient == null) { 1985 commoneventmanager.publish("Sub_Misc_inputMethod_deleteBackward_sync_0261", commonEventPublishData, this.publishCallback); 1986 } else { 1987 try { 1988 // @ts-ignore 1989 InputClient.deleteBackwardSync(false); 1990 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0261 deleteBackwardSync over'); 1991 } catch (err) { 1992 console.info(TAG + '====>Sub_Misc_inputMethod_deleteBackward_sync_0261 deleteBackwardSync err: ' + JSON.stringify(err)); 1993 if(err.code === 401){ 1994 commonEventPublishData = { 1995 data: "SUCCESS" 1996 }; 1997 } 1998 } 1999 commoneventmanager.publish("Sub_Misc_inputMethod_deleteBackward_sync_0261", commonEventPublishData, this.publishCallback); 2000 } 2001 }); 2002 } 2003 2004 private Sub_Misc_inputMethod_insertText_sync_0270(): void{ 2005 console.info(TAG + '====>receive Sub_Misc_inputMethod_insertText_sync_0270 data'); 2006 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 2007 inputMethodAbility.off('inputStart'); 2008 let commonEventPublishData = { 2009 data: "FAILED" 2010 }; 2011 if (InputClient == null) { 2012 commoneventmanager.publish("Sub_Misc_inputMethod_insertText_sync_0270", commonEventPublishData, this.publishCallback); 2013 } else { 2014 InputClient.insertTextSync('test'); 2015 console.info(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0270 insertTextSync'); 2016 commonEventPublishData = { 2017 data: "SUCCESS" 2018 }; 2019 commoneventmanager.publish("Sub_Misc_inputMethod_insertText_sync_0270", commonEventPublishData, this.publishCallback); 2020 } 2021 }); 2022 } 2023 2024 private Sub_Misc_inputMethod_insertText_sync_0271(): void{ 2025 console.info(TAG + '====>receive Sub_Misc_inputMethod_insertText_sync_0271 data'); 2026 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 2027 inputMethodAbility.off('inputStart'); 2028 let commonEventPublishData = { 2029 data: "FAILED" 2030 }; 2031 if (InputClient == null) { 2032 commoneventmanager.publish("Sub_Misc_inputMethod_insertText_sync_0271", commonEventPublishData, this.publishCallback); 2033 } else { 2034 try { 2035 // @ts-ignore 2036 InputClient.insertTextSync(123); 2037 console.info(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0271 insertTextSync over'); 2038 } catch (err) { 2039 console.info(TAG + '====>Sub_Misc_inputMethod_insertText_sync_0271 insertTextSync err: ' + JSON.stringify(err)); 2040 if(err.code === 401){ 2041 commonEventPublishData = { 2042 data: "SUCCESS" 2043 }; 2044 } 2045 } 2046 commoneventmanager.publish("Sub_Misc_inputMethod_insertText_sync_0271", commonEventPublishData, this.publishCallback); 2047 } 2048 }); 2049 } 2050 2051 private Sub_Misc_inputMethod_selectByRange_sync_0280(): void{ 2052 console.debug(TAG + '====>receive Sub_Misc_inputMethod_selectByRange_sync_0280 data'); 2053 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 2054 inputMethodAbility.off('inputStart'); 2055 let range = { start: 0, end: 1 }; 2056 let commonEventPublishData = { 2057 data: "FAILED" 2058 }; 2059 if (InputClient == null) { 2060 commoneventmanager.publish("Sub_Misc_inputMethod_selectByRange_sync_0280", commonEventPublishData, this.publishCallback); 2061 } else { 2062 try { 2063 InputClient.selectByRangeSync(range); 2064 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0280 selectByRangeSync success' ); 2065 commonEventPublishData = { 2066 data: "SUCCESS" 2067 }; 2068 } catch (err) { 2069 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0280 selectByRangeSync err: ' + JSON.stringify(err)); 2070 } 2071 commoneventmanager.publish("Sub_Misc_inputMethod_selectByRange_sync_0280", commonEventPublishData, this.publishCallback); 2072 } 2073 }); 2074 } 2075 2076 private Sub_Misc_inputMethod_selectByRange_sync_0281(): void{ 2077 console.info(TAG + '====>receive Sub_Misc_inputMethod_selectByRange_sync_0281 data'); 2078 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 2079 inputMethodAbility.off('inputStart'); 2080 let commonEventPublishData = { 2081 data: "FAILED" 2082 }; 2083 if (InputClient == null) { 2084 commoneventmanager.publish("Sub_Misc_inputMethod_selectByRange_sync_0281", commonEventPublishData, this.publishCallback); 2085 } else { 2086 try { 2087 // @ts-ignore 2088 InputClient.selectByRangeSync(true); 2089 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0281 selectByRangeSync over'); 2090 } catch (err) { 2091 console.info(TAG + '====>Sub_Misc_inputMethod_selectByRange_sync_0281 selectByRangeSync err: ' + JSON.stringify(err)); 2092 if(err.code === 401){ 2093 commonEventPublishData = { 2094 data: "SUCCESS" 2095 }; 2096 } 2097 } 2098 commoneventmanager.publish("Sub_Misc_inputMethod_selectByRange_sync_0281", commonEventPublishData, this.publishCallback); 2099 } 2100 }); 2101 } 2102 2103 private Sub_Misc_inputMethod_selectByMovement_sync_0290(): void{ 2104 console.debug(TAG + '====>receive Sub_Misc_inputMethod_selectByMovement_sync_0290 data'); 2105 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 2106 inputMethodAbility.off('inputStart'); 2107 let movement = { direction: inputMethodEngine.CURSOR_DOWN }; 2108 let commonEventPublishData = { 2109 data: "FAILED" 2110 }; 2111 if (InputClient == null) { 2112 commoneventmanager.publish("Sub_Misc_inputMethod_selectByMovement_sync_0290", commonEventPublishData, this.publishCallback); 2113 } else { 2114 try { 2115 InputClient.selectByMovementSync(movement); 2116 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0290 selectByMovementSync success' ); 2117 commonEventPublishData = { 2118 data: "SUCCESS" 2119 }; 2120 } catch (err) { 2121 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0290 selectByMovementSync err: ' + JSON.stringify(err)); 2122 } 2123 commoneventmanager.publish("Sub_Misc_inputMethod_selectByMovement_sync_0290", commonEventPublishData, this.publishCallback); 2124 } 2125 }); 2126 } 2127 2128 private Sub_Misc_inputMethod_selectByMovement_sync_0291(): void{ 2129 console.info(TAG + '====>receive Sub_Misc_inputMethod_selectByMovement_sync_0291 data'); 2130 inputMethodAbility.on('inputStart', async(KeyboardDelegate, InputClient) =>{ 2131 inputMethodAbility.off('inputStart'); 2132 let commonEventPublishData = { 2133 data: "FAILED" 2134 }; 2135 if (InputClient == null) { 2136 commoneventmanager.publish("Sub_Misc_inputMethod_selectByMovement_sync_0291", commonEventPublishData, this.publishCallback); 2137 } else { 2138 try { 2139 // @ts-ignore 2140 InputClient.selectByMovementSync(true); 2141 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0291 selectByMovementSync over'); 2142 } catch (err) { 2143 console.info(TAG + '====>Sub_Misc_inputMethod_selectByMovement_sync_0291 selectByMovementSync err: ' + JSON.stringify(err)); 2144 if(err.code === 401){ 2145 commonEventPublishData = { 2146 data: "SUCCESS" 2147 }; 2148 } 2149 } 2150 commoneventmanager.publish("Sub_Misc_inputMethod_selectByMovement_sync_0291", commonEventPublishData, this.publishCallback); 2151 } 2152 }); 2153 } 2154 2155 2156}