1/* 2 * Copyright (c) 2021 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 */ 15 16import {AsyncCallback} from './basic'; 17import InputMethodSubtype from './@ohos.InputMethodSubtype'; 18 19/** 20 * Input method engine 21 * 22 * @since 8 23 * @syscap SystemCapability.MiscServices.InputMethodFramework 24 */ 25declare namespace inputMethodEngine { 26 /** 27 * When "enter" key is pressed, there is no action 28 * @since 8 29 * @syscap SystemCapability.MiscServices.InputMethodFramework 30 */ 31 const ENTER_KEY_TYPE_UNSPECIFIED: number; 32 33 /** 34 * When "enter" key is pressed, it means GO 35 * @since 8 36 * @syscap SystemCapability.MiscServices.InputMethodFramework 37 */ 38 const ENTER_KEY_TYPE_GO: number; 39 40 /** 41 * When "enter" key is pressed, it means SEARCH 42 * @since 8 43 * @syscap SystemCapability.MiscServices.InputMethodFramework 44 */ 45 const ENTER_KEY_TYPE_SEARCH: number; 46 47 /** 48 * When "enter" key is pressed, it means SEND 49 * @since 8 50 * @syscap SystemCapability.MiscServices.InputMethodFramework 51 */ 52 const ENTER_KEY_TYPE_SEND: number; 53 54 /** 55 * When "enter" key is pressed, it means NEXT 56 * @since 8 57 * @syscap SystemCapability.MiscServices.InputMethodFramework 58 */ 59 const ENTER_KEY_TYPE_NEXT: number; 60 61 /** 62 * When "enter" key is pressed, it means DONE 63 * @since 8 64 * @syscap SystemCapability.MiscServices.InputMethodFramework 65 */ 66 const ENTER_KEY_TYPE_DONE: number; 67 68 /** 69 * When "enter" key is pressed, it means PREVIOUS 70 * @since 8 71 * @syscap SystemCapability.MiscServices.InputMethodFramework 72 */ 73 const ENTER_KEY_TYPE_PREVIOUS: number; 74 75 /** 76 * Editor with no special function 77 * @since 8 78 * @syscap SystemCapability.MiscServices.InputMethodFramework 79 */ 80 const PATTERN_NULL: number; 81 82 /** 83 * Editor of type TEXT 84 * @since 8 85 * @syscap SystemCapability.MiscServices.InputMethodFramework 86 */ 87 const PATTERN_TEXT: number; 88 89 /** 90 * Editor of type NUMBER 91 * @since 8 92 * @syscap SystemCapability.MiscServices.InputMethodFramework 93 */ 94 const PATTERN_NUMBER: number; 95 96 /** 97 * Editor of type PHONE NUMBER 98 * @since 8 99 * @syscap SystemCapability.MiscServices.InputMethodFramework 100 */ 101 const PATTERN_PHONE: number; 102 103 /** 104 * Editor of type DATETIME 105 * @since 8 106 * @syscap SystemCapability.MiscServices.InputMethodFramework 107 */ 108 const PATTERN_DATETIME: number; 109 110 /** 111 * Editor of type EMAIL 112 * @since 8 113 * @syscap SystemCapability.MiscServices.InputMethodFramework 114 */ 115 const PATTERN_EMAIL: number; 116 117 /** 118 * Editor of type URI 119 * @since 8 120 * @syscap SystemCapability.MiscServices.InputMethodFramework 121 */ 122 const PATTERN_URI: number; 123 124 /** 125 * Editor of type PASSWORD 126 * @since 8 127 * @syscap SystemCapability.MiscServices.InputMethodFramework 128 */ 129 const PATTERN_PASSWORD: number; 130 131 /** 132 * Editor in SELECTING state 133 * @since 8 134 * @syscap SystemCapability.MiscServices.InputMethodFramework 135 */ 136 const FLAG_SELECTING: number; 137 138 /** 139 * Editor in SINGLE_LINE state 140 * @since 8 141 * @syscap SystemCapability.MiscServices.InputMethodFramework 142 */ 143 const FLAG_SINGLE_LINE: number; 144 145 /** 146 * The Editor displays in PART mode 147 * @since 8 148 * @syscap SystemCapability.MiscServices.InputMethodFramework 149 */ 150 const DISPLAY_MODE_PART: number; 151 152 /** 153 * The Editor displays in FULL mode 154 * @since 8 155 * @syscap SystemCapability.MiscServices.InputMethodFramework 156 */ 157 const DISPLAY_MODE_FULL: number; 158 159 /** 160 * Allows ASCII to be inputted 161 * @since 8 162 * @syscap SystemCapability.MiscServices.InputMethodFramework 163 */ 164 const OPTION_ASCII: number; 165 166 /** 167 * Do not specify Editor's input type 168 * @since 8 169 * @syscap SystemCapability.MiscServices.InputMethodFramework 170 */ 171 const OPTION_NONE: number; 172 173 /** 174 * Allows CHARACTERS to be inputted 175 * @since 8 176 * @syscap SystemCapability.MiscServices.InputMethodFramework 177 */ 178 const OPTION_AUTO_CAP_CHARACTERS: number; 179 180 /** 181 * Allows SENTENCES to be inputted 182 * @since 8 183 * @syscap SystemCapability.MiscServices.InputMethodFramework 184 */ 185 const OPTION_AUTO_CAP_SENTENCES: number; 186 187 /** 188 * Allows WORDS to be inputted 189 * @since 8 190 * @syscap SystemCapability.MiscServices.InputMethodFramework 191 */ 192 const OPTION_AUTO_WORDS: number; 193 194 /** 195 * Allows MULTI_LINE to be inputted 196 * @since 8 197 * @syscap SystemCapability.MiscServices.InputMethodFramework 198 */ 199 const OPTION_MULTI_LINE: number; 200 201 /** 202 * Half-screen mode 203 * @since 8 204 * @syscap SystemCapability.MiscServices.InputMethodFramework 205 */ 206 const OPTION_NO_FULLSCREEN: number; 207 208 /** 209 * The move direction of cursor: UP 210 * @since 9 211 * @syscap SystemCapability.MiscServices.InputMethodFramework 212 */ 213 const CURSOR_UP: number; 214 215 /** 216 * The move direction of cursor: DOWN 217 * @since 9 218 * @syscap SystemCapability.MiscServices.InputMethodFramework 219 */ 220 const CURSOR_DOWN: number; 221 222 /** 223 * The move direction of cursor: LEFT 224 * @since 9 225 * @syscap SystemCapability.MiscServices.InputMethodFramework 226 */ 227 const CURSOR_LEFT: number; 228 229 /** 230 * The move direction of cursor: RIGHT 231 * @since 9 232 * @syscap SystemCapability.MiscServices.InputMethodFramework 233 */ 234 const CURSOR_RIGHT: number; 235 236 /** 237 * The window styles for input method ability. 238 * @since 9 239 * @syscap SystemCapability.MiscServices.InputMethodFramework 240 */ 241 const WINDOW_TYPE_INPUT_METHOD_FLOAT: number; 242 243 /** 244 * Get InputMethodAbility object to subscribe events about IME. 245 * @returns { InputMethodAbility } the object of the InputMethodAbility. 246 * @syscap SystemCapability.MiscServices.InputMethodFramework 247 * @since 9 248 */ 249 function getInputMethodAbility(): InputMethodAbility; 250 251 /** 252 * @since 8 253 * @deprecated since 9 254 * @useinstead ohos.inputMethodEngine.getInputMethodAbility 255 */ 256 function getInputMethodEngine(): InputMethodEngine; 257 258 /** 259 * Get KeyboardDelegate object to subscribe key event or events about editor. 260 * @returns { KeyboardDelegate } the object of KeyboardDelegate. 261 * @syscap SystemCapability.MiscServices.InputMethodFramework 262 * @since 9 263 */ 264 function getKeyboardDelegate(): KeyboardDelegate; 265 266 /** 267 * @since 8 268 * @deprecated since 9 269 * @useinstead ohos.inputMethodEngine.getKeyboardDelegate 270 */ 271 function createKeyboardDelegate(): KeyboardDelegate; 272 273 /** 274 * @since 8 275 */ 276 interface KeyboardController { 277 /** 278 * Hide soft keyboard 279 * @throws {BusinessError} 12800003 - input method client error. 280 * @syscap SystemCapability.MiscServices.InputMethodFramework 281 * @since 9 282 */ 283 hide(callback: AsyncCallback<void>): void; 284 285 /** 286 * Hide soft keyboard 287 * @throws {BusinessError} 12800003 - input method client error. 288 * @syscap SystemCapability.MiscServices.InputMethodFramework 289 * @since 9 290 */ 291 hide(): Promise<void>; 292 293 /** 294 * @since 8 295 * @deprecated since 9 296 * @useinstead ohos.inputMethodEngine.KeyboardController.hide 297 */ 298 hideKeyboard(callback: AsyncCallback<void>): void; 299 300 /** 301 * @since 8 302 * @deprecated since 9 303 * @useinstead ohos.inputMethodEngine.KeyboardController.hide 304 */ 305 hideKeyboard(): Promise<void>; 306 } 307 308 /** 309 * @since 8 310 */ 311 interface InputMethodEngine { 312 /** 313 * Subscribe 'inputStart' 314 * @since 8 315 * @param type inputStart 316 * @param callback give keyboard controller and text input client 317 */ 318 on(type: 'inputStart', callback: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; 319 320 /** 321 * Unsubscribe 'inputStart' 322 * @since 8 323 * @param type inputStart 324 * @param callback optional, give keyboard controller and text input client 325 */ 326 off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; 327 328 /** 329 * Subscribe 'keyboardShow'|'keyboardHide' 330 * @since 8 331 * @param type keyboardShow|keyboardHide 332 */ 333 on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void; 334 335 /** 336 * Unsubscribe 'keyboardShow'|'keyboardHide' 337 * @since 8 338 * @param type keyboardShow|keyboardHide 339 */ 340 off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void; 341 } 342 343 /** 344 * <p>Control events about IME.</p> 345 * <p>Events provided for IME to subscribe with callback function. When those events occur, the corresponding callback 346 * will be invoked.</p> 347 * @interface InputMethodAbility 348 * @syscap SystemCapability.MiscServices.InputMethodFramework 349 * @since 9 350 */ 351 interface InputMethodAbility { 352 /** 353 * Subscribe 'inputStart' event. 354 * @since 9 355 * @param { 'inputStart' } type - the type of subscribe event. 356 * @param { (kbController: KeyboardController, inputClient: InputClient) => void) } callback - the callback of on('inputStart'). 357 * @syscap SystemCapability.MiscServices.InputMethodFramework 358 */ 359 on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: InputClient) => void): void; 360 361 /** 362 * Unsubscribe 'inputStart' event. 363 * @since 9 364 * @param { 'inputStart' } type - the type of unsubscribe event. 365 * @param { (kbController: KeyboardController, inputClient: InputClient) => void) } [callback] - the callback of off('inputStart'). 366 * @syscap SystemCapability.MiscServices.InputMethodFramework 367 */ 368 off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClient: InputClient) => void): void; 369 370 /** 371 * Subscribe 'inputStop'. 372 * @since 9 373 * @param { 'inputStop' } type - the type of subscribe event. 374 * @param { () => void } callback - the callback of on('inputStop'). 375 * @syscap SystemCapability.MiscServices.InputMethodFramework 376 */ 377 on(type: 'inputStop', callback: () => void): void; 378 379 /** 380 * Unsubscribe 'inputStop'. 381 * @since 9 382 * @param { 'inputStop' } type - the type of unsubscribe event. 383 * @param { () => void } callback - the callback of off('inputStop'). 384 * @syscap SystemCapability.MiscServices.InputMethodFramework 385 */ 386 off(type: 'inputStop', callback: () => void): void; 387 388 /** 389 * Subscribe 'setCallingWindow'. 390 * @since 9 391 * @param { 'setCallingWindow' } type - the type of subscribe event. 392 * @param { (wid:number) => void } callback - the callback of on('setCallingWindow'). 393 * @syscap SystemCapability.MiscServices.InputMethodFramework 394 */ 395 on(type: 'setCallingWindow', callback: (wid:number) => void): void; 396 397 /** 398 * Unsubscribe 'setCallingWindow'. 399 * @since 9 400 * @param { 'setCallingWindow' } type - the type of unsubscribe event. 401 * @param { (wid:number) => void } callback - the callback of off('setCallingWindow'). 402 * @syscap SystemCapability.MiscServices.InputMethodFramework 403 */ 404 off(type: 'setCallingWindow', callback: (wid:number) => void): void; 405 406 /** 407 * Subscribe 'keyboardShow'|'keyboardHide'. 408 * @since 9 409 * @param { 'keyboardShow'|'keyboardHide' } type - the type of subscribe event. 410 * @param { () => void } callback - the callback of on('keyboardShow'|'keyboardHide'). 411 * @syscap SystemCapability.MiscServices.InputMethodFramework 412 */ 413 on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void; 414 415 /** 416 * Unsubscribe 'keyboardShow'|'keyboardHide'. 417 * @since 9 418 * @param { 'keyboardShow'|'keyboardHide' } type - the type of unsubscribe event. 419 * @param { () => void } [callback] - the callback of off('keyboardShow'|'keyboardHide'). 420 * @syscap SystemCapability.MiscServices.InputMethodFramework 421 */ 422 off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void; 423 424 /** 425 * Subscribe 'setSubtype'. 426 * @since 9 427 * @param { 'setSubtype' } type - the type of subscribe event. 428 * @param { (inputMethodSubtype: InputMethodSubtype) => void } callback - the callback of on('setSubtype'). 429 * @syscap SystemCapability.MiscServices.InputMethodFramework 430 */ 431 on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => void): void; 432 433 /** 434 * Unsubscribe 'setSubtype'. 435 * @since 9 436 * @param { 'setSubtype' } type - the type of subscribe event. 437 * @param { (inputMethodSubtype: InputMethodSubtype) => void } [callback] - the callback of off('setSubtype'). 438 * @syscap SystemCapability.MiscServices.InputMethodFramework 439 */ 440 off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void; 441 } 442 443 /** 444 * @since 8 445 * @deprecated since 9 446 * @useinstead ohos.inputMethodEngine.InputClient 447 */ 448 interface TextInputClient { 449 /** 450 * @since 8 451 * @deprecated since 9 452 * @useinstead ohos.inputMethodEngine.InputClient.sendKeyFunction 453 */ 454 sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void; 455 456 /** 457 * @since 8 458 * @deprecated since 9 459 * @useinstead ohos.inputMethodEngine.InputClient.sendKeyFunction 460 */ 461 sendKeyFunction(action: number): Promise<boolean>; 462 463 /** 464 * @since 8 465 * @deprecated since 9 466 * @useinstead ohos.inputMethodEngine.InputClient.deleteForward 467 */ 468 deleteForward(length: number, callback: AsyncCallback<boolean>): void; 469 470 /** 471 * @since 8 472 * @deprecated since 9 473 * @useinstead ohos.inputMethodEngine.InputClient.deleteForward 474 */ 475 deleteForward(length: number): Promise<boolean>; 476 477 /** 478 * @since 8 479 * @deprecated since 9 480 * @useinstead ohos.inputMethodEngine.InputClient.deleteBackward 481 */ 482 deleteBackward(length: number, callback: AsyncCallback<boolean>): void; 483 484 /** 485 * @since 8 486 * @deprecated since 9 487 * @useinstead ohos.inputMethodEngine.InputClient.deleteBackward 488 */ 489 deleteBackward(length: number): Promise<boolean>; 490 491 /** 492 * @since 8 493 * @deprecated since 9 494 * @useinstead ohos.inputMethodEngine.InputClient.insertText 495 */ 496 insertText(text: string, callback: AsyncCallback<boolean>): void; 497 498 /** 499 * @since 8 500 * @deprecated since 9 501 * @useinstead ohos.inputMethodEngine.InputClient.insertText 502 */ 503 insertText(text: string): Promise<boolean>; 504 505 /** 506 * @since 8 507 * @deprecated since 9 508 * @useinstead ohos.inputMethodEngine.InputClient.getForward 509 */ 510 getForward(length: number, callback: AsyncCallback<string>): void; 511 512 /** 513 * @since 8 514 * @deprecated since 9 515 * @useinstead ohos.inputMethodEngine.InputClient.getForward 516 */ 517 getForward(length: number): Promise<string>; 518 519 /** 520 * @since 8 521 * @deprecated since 9 522 * @useinstead ohos.inputMethodEngine.InputClient.getBackward 523 */ 524 getBackward(length: number, callback: AsyncCallback<string>): void; 525 526 /** 527 * @since 8 528 * @deprecated since 9 529 * @useinstead ohos.inputMethodEngine.InputClient.getBackward 530 */ 531 getBackward(length: number): Promise<string>; 532 533 /** 534 * @since 8 535 * @deprecated since 9 536 * @useinstead ohos.inputMethodEngine.InputClient.getEditorAttribute 537 */ 538 getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void; 539 540 /** 541 * @since 8 542 * @deprecated since 9 543 * @useinstead ohos.inputMethodEngine.InputClient.getEditorAttribute 544 */ 545 getEditorAttribute(): Promise<EditorAttribute>; 546 } 547 548 /** 549 * Control events about Editor. 550 * @interface InputClient 551 * @syscap SystemCapability.MiscServices.InputMethodFramework 552 * @since 9 553 */ 554 interface InputClient { 555 /** 556 * Send the function of the key. 557 * @since 9 558 * @param { number } action - action indicates the function of "enter" key. 559 * @param { AsyncCallback<boolean> } callback - the callback of sendKeyFunction. 560 * @throws { BusinessError } 401 - parameter error. 561 * @throws { BusinessError } 12800003 - input method client error. 562 * @syscap SystemCapability.MiscServices.InputMethodFramework 563 */ 564 sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void; 565 566 /** 567 * Send the function of the key. 568 * @since 9 569 * @param { number } action - action indicates the function of "enter" key. 570 * @returns { Promise<boolean> } the promise returned by the function. 571 * @throws { BusinessError } 401 - parameter error. 572 * @throws { BusinessError } 12800003 - input method client error. 573 * @syscap SystemCapability.MiscServices.InputMethodFramework 574 */ 575 sendKeyFunction(action: number): Promise<boolean>; 576 577 /** 578 * Delete text forward. 579 * @since 9 580 * @param { number } length - length of text which will be deleted forward. 581 * @param { AsyncCallback<boolean> } callback - the callback of deleteForward. 582 * @throws { BusinessError } 401 - parameter error. 583 * @throws { BusinessError } 12800002 - Input method engine error. 584 * @throws { BusinessError } 12800003 - input method client error. 585 * @syscap SystemCapability.MiscServices.InputMethodFramework 586 */ 587 deleteForward(length: number, callback: AsyncCallback<boolean>): void; 588 589 /** 590 * Delete text forward. 591 * @param { number } length - length of text which will be deleted forward. 592 * @returns { Promise<boolean> } the promise returned by the function. 593 * @throws { BusinessError } 401 - parameter error. 594 * @throws { BusinessError } 12800002 - Input method engine error. 595 * @throws { BusinessError } 12800003 - input method client error. 596 * @syscap SystemCapability.MiscServices.InputMethodFramework 597 * @since 9 598 */ 599 deleteForward(length: number): Promise<boolean>; 600 601 /** 602 * Delete text backward. 603 * @param { number } length - length of text which will be deleted backward. 604 * @param { AsyncCallback<boolean> } callback - the callback of deleteBackward. 605 * @throws { BusinessError } 401 - parameter error. 606 * @throws { BusinessError } 12800002 - Input method engine error. 607 * @throws { BusinessError } 12800003 - input method client error. 608 * @syscap SystemCapability.MiscServices.InputMethodFramework 609 * @since 9 610 */ 611 deleteBackward(length: number, callback: AsyncCallback<boolean>): void; 612 613 /** 614 * Delete text backward. 615 * @param { number } length - length of text which will be deleted backward. 616 * @returns { Promise<boolean> } the promise returned by the function. 617 * @throws { BusinessError } 401 - parameter error. 618 * @throws { BusinessError } 12800002 - Input method engine error. 619 * @throws { BusinessError } 12800003 - input method client error. 620 * @syscap SystemCapability.MiscServices.InputMethodFramework 621 * @since 9 622 */ 623 deleteBackward(length: number): Promise<boolean>; 624 625 /** 626 * Insert text into Editor. 627 * @param { string } text - text which will be inserted. 628 * @param { AsyncCallback<boolean> } callback - the callback of insertText. 629 * @throws { BusinessError } 401 - parameter error. 630 * @throws { BusinessError } 12800002 - Input method engine error. 631 * @throws { BusinessError } 12800003 - input method client error. 632 * @syscap SystemCapability.MiscServices.InputMethodFramework 633 * @since 9 634 */ 635 insertText(text: string, callback: AsyncCallback<boolean>): void; 636 637 /** 638 * Insert text into Editor. 639 * @param { string } text - text which will be inserted. 640 * @returns { Promise<boolean> } the promise returned by the function. 641 * @throws { BusinessError } 401 - parameter error. 642 * @throws { BusinessError } 12800002 - Input method engine error. 643 * @throws { BusinessError } 12800003 - input method client error. 644 * @syscap SystemCapability.MiscServices.InputMethodFramework 645 * @since 9 646 */ 647 insertText(text: string): Promise<boolean>; 648 649 /** 650 * Get the text before cursor. 651 * @param { number } length - the length of text which will be got. 652 * @param { AsyncCallback<string> } callback - the callback of getForward. 653 * @throws { BusinessError } 401 - parameter error. 654 * @throws { BusinessError } 12800003 - input method client error. 655 * @throws { BusinessError } 12800006 - Input method controller error. 656 * @syscap SystemCapability.MiscServices.InputMethodFramework 657 * @since 9 658 */ 659 getForward(length: number, callback: AsyncCallback<string>): void; 660 661 /** 662 * Get the text before cursor. 663 * @param { number } length - the length of text which will be got. 664 * @returns { Promise<string> } the promise returned by the function. 665 * @throws { BusinessError } 401 - parameter error. 666 * @throws { BusinessError } 12800003 - input method client error. 667 * @throws { BusinessError } 12800006 - Input method controller error. 668 * @syscap SystemCapability.MiscServices.InputMethodFramework 669 * @since 9 670 */ 671 getForward(length: number): Promise<string>; 672 673 /** 674 * Get the text after cursor. 675 * @param { number } length - the length of text which will be got. 676 * @param { AsyncCallback<string> } callback - the callback of getBackward. 677 * @throws { BusinessError } 401 - parameter error. 678 * @throws { BusinessError } 12800003 - input method client error. 679 * @throws { BusinessError } 12800006 - Input method controller error. 680 * @syscap SystemCapability.MiscServices.InputMethodFramework 681 * @since 9 682 */ 683 getBackward(length: number, callback: AsyncCallback<string>): void; 684 685 /** 686 * Get the text after cursor. 687 * @param { number } length - the length of text which will be got. 688 * @returns { Promise<string> } the promise returned by the function. 689 * @throws { BusinessError } 401 - parameter error. 690 * @throws { BusinessError } 12800003 - input method client error. 691 * @throws { BusinessError } 12800006 - Input method controller error. 692 * @syscap SystemCapability.MiscServices.InputMethodFramework 693 * @since 9 694 */ 695 getBackward(length: number): Promise<string>; 696 697 /** 698 * Get attribute about editor. 699 * @param { AsyncCallback<EditorAttribute> } callback - the callback of getEditorAttribute. 700 * @throws { BusinessError } 12800003 - input method client error. 701 * @syscap SystemCapability.MiscServices.InputMethodFramework 702 * @since 9 703 */ 704 getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void; 705 706 /** 707 * Get attribute about editor. 708 * @since 9 709 * @returns { Promise<EditorAttribute> } the promise returned by the function. 710 * @throws { BusinessError } 12800003 - input method client error. 711 * @syscap SystemCapability.MiscServices.InputMethodFramework 712 */ 713 getEditorAttribute(): Promise<EditorAttribute>; 714 715 /** 716 * Move cursor from input method. 717 * 718 * @since 9 719 * @syscap SystemCapability.MiscServices.InputMethodFramework 720 * @param { number } direction - Indicates the distance of cursor to be moved. 721 * @param { AsyncCallback<void> } callback - the callback of moveCursor. 722 * @throws { BusinessError } 401 - parameter error. 723 * @throws { BusinessError } 12800003 - input method client error. 724 */ 725 moveCursor(direction: number, callback: AsyncCallback<void>): void; 726 727 /** 728 * Move cursor from input method. 729 * 730 * @since 9 731 * @syscap SystemCapability.MiscServices.InputMethodFramework 732 * @param { number } direction - Indicates the distance of cursor to be moved. 733 * @returns { Promise<void> } the promise returned by the function. 734 * @throws { BusinessError } 401 - parameter error. 735 * @throws { BusinessError } 12800003 - input method client error. 736 */ 737 moveCursor(direction: number): Promise<void>; 738 } 739 740 /** 741 * @since 8 742 */ 743 interface KeyboardDelegate { 744 /** 745 * Subscribe key up or down event 746 * 747 * @since 8 748 */ 749 on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void; 750 751 /** 752 * Unsubscribe key up or down event 753 * 754 * @since 8 755 */ 756 off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void; 757 758 /** 759 * Subscribe cursor context change 760 * 761 * @since 8 762 */ 763 on(type: 'cursorContextChange', callback: (x: number, y: number, height: number) => void): void; 764 765 /** 766 * Unsubscribe cursor context change 767 * 768 * @since 8 769 */ 770 off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void; 771 772 /** 773 * Subscribe selection change 774 * 775 * @since 8 776 */ 777 on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; 778 779 /** 780 * Unsubscribe selection change 781 * 782 * @since 8 783 */ 784 off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; 785 786 /** 787 * Subscribe text change 788 * 789 * @since 8 790 */ 791 on(type: 'textChange', callback: (text: string) => void): void; 792 793 /** 794 * Unsubscribe text change 795 * 796 * @since 8 797 */ 798 off(type: 'textChange', callback?: (text: string) => void): void; 799 } 800 801 /** 802 * @since 8 803 */ 804 interface EditorAttribute { 805 /** 806 * Editor's pattern 807 * 808 * @since 8 809 * @syscap SystemCapability.MiscServices.InputMethodFramework 810 */ 811 readonly inputPattern: number; 812 813 /** 814 * Editor's key type 815 * 816 * @since 8 817 * @syscap SystemCapability.MiscServices.InputMethodFramework 818 */ 819 readonly enterKeyType: number; 820 } 821 822 /** 823 * @since 8 824 */ 825 interface KeyEvent { 826 /** 827 * Key code 828 * 829 * @since 8 830 */ 831 readonly keyCode: number; 832 833 /** 834 * Key action 835 * 836 * @since 8 837 */ 838 readonly keyAction: number; 839 } 840} 841 842export default inputMethodEngine; 843