1/* 2 * Copyright (c) 2021-2024 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 16/** 17 * @file 18 * @kit IMEKit 19 */ 20import type { AsyncCallback, Callback } from './@ohos.base'; 21import type { KeyEvent as InputKeyEvent } from './@ohos.multimodalInput.keyEvent'; 22import InputMethodSubtype from './@ohos.InputMethodSubtype'; 23import BaseContext from './application/BaseContext'; 24import window from './@ohos.window'; 25 26/** 27 * Input method engine 28 * 29 * @namespace inputMethodEngine 30 * @syscap SystemCapability.MiscServices.InputMethodFramework 31 * @since 8 32 */ 33declare namespace inputMethodEngine { 34 /** 35 * When "enter" key is pressed, there is no action 36 * 37 * @syscap SystemCapability.MiscServices.InputMethodFramework 38 * @since 8 39 */ 40 const ENTER_KEY_TYPE_UNSPECIFIED: number; 41 42 /** 43 * When "enter" key is pressed, it means GO 44 * 45 * @syscap SystemCapability.MiscServices.InputMethodFramework 46 * @since 8 47 */ 48 const ENTER_KEY_TYPE_GO: number; 49 50 /** 51 * When "enter" key is pressed, it means SEARCH 52 * 53 * @syscap SystemCapability.MiscServices.InputMethodFramework 54 * @since 8 55 */ 56 const ENTER_KEY_TYPE_SEARCH: number; 57 58 /** 59 * When "enter" key is pressed, it means SEND 60 * 61 * @syscap SystemCapability.MiscServices.InputMethodFramework 62 * @since 8 63 */ 64 const ENTER_KEY_TYPE_SEND: number; 65 66 /** 67 * When "enter" key is pressed, it means NEXT 68 * 69 * @syscap SystemCapability.MiscServices.InputMethodFramework 70 * @since 8 71 */ 72 const ENTER_KEY_TYPE_NEXT: number; 73 74 /** 75 * When "enter" key is pressed, it means DONE 76 * 77 * @syscap SystemCapability.MiscServices.InputMethodFramework 78 * @since 8 79 */ 80 const ENTER_KEY_TYPE_DONE: number; 81 82 /** 83 * When "enter" key is pressed, it means PREVIOUS 84 * 85 * @syscap SystemCapability.MiscServices.InputMethodFramework 86 * @since 8 87 */ 88 const ENTER_KEY_TYPE_PREVIOUS: number; 89 90 /** 91 * When "enter" key is pressed, it means NEWLINE 92 * 93 * @constant 94 * @syscap SystemCapability.MiscServices.InputMethodFramework 95 * @since 12 96 */ 97 const ENTER_KEY_TYPE_NEWLINE: 8; 98 99 /** 100 * Editor with no special function 101 * 102 * @syscap SystemCapability.MiscServices.InputMethodFramework 103 * @since 8 104 */ 105 const PATTERN_NULL: number; 106 107 /** 108 * Editor of type TEXT 109 * 110 * @syscap SystemCapability.MiscServices.InputMethodFramework 111 * @since 8 112 */ 113 const PATTERN_TEXT: number; 114 115 /** 116 * Editor of type NUMBER 117 * 118 * @syscap SystemCapability.MiscServices.InputMethodFramework 119 * @since 8 120 */ 121 const PATTERN_NUMBER: number; 122 123 /** 124 * Editor of type PHONE NUMBER 125 * 126 * @syscap SystemCapability.MiscServices.InputMethodFramework 127 * @since 8 128 */ 129 const PATTERN_PHONE: number; 130 131 /** 132 * Editor of type DATETIME 133 * 134 * @syscap SystemCapability.MiscServices.InputMethodFramework 135 * @since 8 136 */ 137 const PATTERN_DATETIME: number; 138 139 /** 140 * Editor of type EMAIL 141 * 142 * @syscap SystemCapability.MiscServices.InputMethodFramework 143 * @since 8 144 */ 145 const PATTERN_EMAIL: number; 146 147 /** 148 * Editor of type URI 149 * 150 * @syscap SystemCapability.MiscServices.InputMethodFramework 151 * @since 8 152 */ 153 const PATTERN_URI: number; 154 155 /** 156 * Editor of type PASSWORD 157 * 158 * @syscap SystemCapability.MiscServices.InputMethodFramework 159 * @since 8 160 */ 161 const PATTERN_PASSWORD: number; 162 163 /** 164 * Editor of type SCREEN LOCK PASSWORD 165 * 166 * @syscap SystemCapability.MiscServices.InputMethodFramework 167 * @since 11 168 */ 169 const PATTERN_PASSWORD_SCREEN_LOCK: number; 170 171 /** 172 * Editor of type NUMBER PASSWORD 173 * 174 * @syscap SystemCapability.MiscServices.InputMethodFramework 175 * @since 11 176 */ 177 const PATTERN_PASSWORD_NUMBER: number; 178 179 /** 180 * Editor of type PATTERN_USER_NAME 181 * 182 * @constant 183 * @syscap SystemCapability.MiscServices.InputMethodFramework 184 * @since 20 185 */ 186 const PATTERN_USER_NAME: number = 10; 187 188 /** 189 * Editor of type PATTERN_NEW_PASSWORD 190 * 191 * @constant 192 * @syscap SystemCapability.MiscServices.InputMethodFramework 193 * @since 20 194 */ 195 const PATTERN_NEW_PASSWORD: number = 11; 196 197 /** 198 * Editor of type PATTERN_NUMBER_DECIMAL 199 * 200 * @constant 201 * @syscap SystemCapability.MiscServices.InputMethodFramework 202 * @since 20 203 */ 204 const PATTERN_NUMBER_DECIMAL: number = 12; 205 206 /** 207 * Editor of type PATTERN_ONE_TIME_CODE 208 * 209 * @constant 210 * @syscap SystemCapability.MiscServices.InputMethodFramework 211 * @since 20 212 */ 213 const PATTERN_ONE_TIME_CODE: number = 13; 214 215 /** 216 * Editor in SELECTING state 217 * 218 * @syscap SystemCapability.MiscServices.InputMethodFramework 219 * @since 8 220 */ 221 const FLAG_SELECTING: number; 222 223 /** 224 * Editor in SINGLE_LINE state 225 * 226 * @syscap SystemCapability.MiscServices.InputMethodFramework 227 * @since 8 228 */ 229 const FLAG_SINGLE_LINE: number; 230 231 /** 232 * The Editor displays in PART mode 233 * 234 * @syscap SystemCapability.MiscServices.InputMethodFramework 235 * @since 8 236 */ 237 const DISPLAY_MODE_PART: number; 238 239 /** 240 * The Editor displays in FULL mode 241 * 242 * @syscap SystemCapability.MiscServices.InputMethodFramework 243 * @since 8 244 */ 245 const DISPLAY_MODE_FULL: number; 246 247 /** 248 * Allows ASCII to be inputted 249 * 250 * @syscap SystemCapability.MiscServices.InputMethodFramework 251 * @since 8 252 */ 253 const OPTION_ASCII: number; 254 255 /** 256 * Do not specify Editor's input type 257 * 258 * @syscap SystemCapability.MiscServices.InputMethodFramework 259 * @since 8 260 */ 261 const OPTION_NONE: number; 262 263 /** 264 * Allows CHARACTERS to be inputted 265 * 266 * @syscap SystemCapability.MiscServices.InputMethodFramework 267 * @since 8 268 */ 269 const OPTION_AUTO_CAP_CHARACTERS: number; 270 271 /** 272 * Allows SENTENCES to be inputted 273 * 274 * @syscap SystemCapability.MiscServices.InputMethodFramework 275 * @since 8 276 */ 277 const OPTION_AUTO_CAP_SENTENCES: number; 278 279 /** 280 * Allows WORDS to be inputted 281 * 282 * @syscap SystemCapability.MiscServices.InputMethodFramework 283 * @since 8 284 */ 285 const OPTION_AUTO_WORDS: number; 286 287 /** 288 * Allows MULTI_LINE to be inputted 289 * 290 * @syscap SystemCapability.MiscServices.InputMethodFramework 291 * @since 8 292 */ 293 const OPTION_MULTI_LINE: number; 294 295 /** 296 * Half-screen mode 297 * 298 * @syscap SystemCapability.MiscServices.InputMethodFramework 299 * @since 8 300 */ 301 const OPTION_NO_FULLSCREEN: number; 302 303 /** 304 * The move direction of cursor: UP 305 * 306 * @syscap SystemCapability.MiscServices.InputMethodFramework 307 * @since 9 308 */ 309 const CURSOR_UP: number; 310 311 /** 312 * The move direction of cursor: DOWN 313 * 314 * @syscap SystemCapability.MiscServices.InputMethodFramework 315 * @since 9 316 */ 317 const CURSOR_DOWN: number; 318 319 /** 320 * The move direction of cursor: LEFT 321 * 322 * @syscap SystemCapability.MiscServices.InputMethodFramework 323 * @since 9 324 */ 325 const CURSOR_LEFT: number; 326 327 /** 328 * The move direction of cursor: RIGHT 329 * 330 * @syscap SystemCapability.MiscServices.InputMethodFramework 331 * @since 9 332 */ 333 const CURSOR_RIGHT: number; 334 335 /** 336 * The window styles for input method ability. 337 * 338 * @syscap SystemCapability.MiscServices.InputMethodFramework 339 * @since 9 340 */ 341 const WINDOW_TYPE_INPUT_METHOD_FLOAT: number; 342 343 /** 344 * Get InputMethodAbility object to subscribe events about IME. 345 * 346 * @returns { InputMethodAbility } the object of the InputMethodAbility. 347 * @syscap SystemCapability.MiscServices.InputMethodFramework 348 * @since 9 349 */ 350 function getInputMethodAbility(): InputMethodAbility; 351 352 /** 353 * @returns { InputMethodEngine } 354 * @syscap SystemCapability.MiscServices.InputMethodFramework 355 * @since 8 356 * @deprecated since 9 357 * @useinstead inputMethodEngine#getInputMethodAbility 358 */ 359 function getInputMethodEngine(): InputMethodEngine; 360 361 /** 362 * Get KeyboardDelegate object to subscribe key event or events about editor. 363 * 364 * @returns { KeyboardDelegate } the object of KeyboardDelegate. 365 * @syscap SystemCapability.MiscServices.InputMethodFramework 366 * @since 9 367 */ 368 function getKeyboardDelegate(): KeyboardDelegate; 369 370 /** 371 * @returns { KeyboardDelegate } 372 * @syscap SystemCapability.MiscServices.InputMethodFramework 373 * @since 8 374 * @deprecated since 9 375 * @useinstead inputMethodEngine#getKeyboardDelegate 376 */ 377 function createKeyboardDelegate(): KeyboardDelegate; 378 379 /** 380 * Indicates the possible data types of the command. 381 * @typedef { number | string | boolean } 382 * @syscap SystemCapability.MiscServices.InputMethodFramework 383 * @since 12 384 */ 385 type CommandDataType = number | string | boolean; 386 387 /** 388 * The callback of 'sizeUpdate' event. 389 * 390 * @typedef { function } SizeUpdateCallback. 391 * @param { window.Size } size - panel size. 392 * @param { KeyboardArea } keyboardArea - keyboard area. 393 * @syscap SystemCapability.MiscServices.InputMethodFramework 394 * @systemapi 395 * @since 14 396 */ 397 export type SizeUpdateCallback = (size: window.Size, keyboardArea: KeyboardArea) => void; 398 399 /** 400 * The callback of 'sizeChange' event. 401 * 402 * @typedef { function } SizeChangeCallback. 403 * @param { window.Size } size - panel size. 404 * @param { KeyboardArea } keyboardArea - keyboard area. 405 * @syscap SystemCapability.MiscServices.InputMethodFramework 406 * @since 15 407 */ 408 export type SizeChangeCallback = (size: window.Size, keyboardArea?: KeyboardArea) => void; 409 410 /** 411 * @interface KeyboardController 412 * @syscap SystemCapability.MiscServices.InputMethodFramework 413 * @since 8 414 */ 415 interface KeyboardController { 416 /** 417 * Hide soft keyboard 418 * 419 * @param { AsyncCallback<void> } callback - indicates the callback function of hide. 420 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 421 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 422 * @syscap SystemCapability.MiscServices.InputMethodFramework 423 * @since 9 424 */ 425 hide(callback: AsyncCallback<void>): void; 426 427 /** 428 * Hide soft keyboard 429 * 430 * @returns { Promise<void> } the promise returned by the function 431 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 432 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 433 * @syscap SystemCapability.MiscServices.InputMethodFramework 434 * @since 9 435 */ 436 hide(): Promise<void>; 437 438 /** 439 * @param { AsyncCallback<void> } callback - indicates the callback function of hideKeyboard. 440 * @syscap SystemCapability.MiscServices.InputMethodFramework 441 * @since 8 442 * @deprecated since 9 443 * @useinstead inputMethodEngine.KeyboardController#hide 444 */ 445 hideKeyboard(callback: AsyncCallback<void>): void; 446 447 /** 448 * @returns { Promise<void> } the promise returned by the function 449 * @syscap SystemCapability.MiscServices.InputMethodFramework 450 * @since 8 451 * @deprecated since 9 452 * @useinstead inputMethodEngine.KeyboardController#hide 453 */ 454 hideKeyboard(): Promise<void>; 455 456 /** 457 * Exit the current input type. This function can only be called by default input method configured by system. 458 * 459 * @param { AsyncCallback<void> } callback - the callback of exitCurrentInputType. 460 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 461 * a system error, such as null pointer, IPC exception. 462 * @throws { BusinessError } 12800010 - not the preconfigured default input method. 463 * @syscap SystemCapability.MiscServices.InputMethodFramework 464 * @since 11 465 */ 466 exitCurrentInputType(callback: AsyncCallback<void>): void; 467 468 /** 469 * Exit the current input type. This function can only be called by default input method configured by system. 470 * 471 * @returns { Promise<void> } the promise returned by the function. 472 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 473 * a system error, such as null pointer, IPC exception. 474 * @throws { BusinessError } 12800010 - not the preconfigured default input method. 475 * @syscap SystemCapability.MiscServices.InputMethodFramework 476 * @since 11 477 */ 478 exitCurrentInputType(): Promise<void>; 479 } 480 481 /** 482 * @interface InputMethodEngine 483 * @syscap SystemCapability.MiscServices.InputMethodFramework 484 * @since 8 485 */ 486 interface InputMethodEngine { 487 /** 488 * Subscribe 'inputStart' 489 * 490 * @param { 'inputStart' } type - indicates the type of subscribe event. 491 * @param { function } callback - indicates the callback of on('inputStart'). 492 * @syscap SystemCapability.MiscServices.InputMethodFramework 493 * @since 8 494 */ 495 on( 496 type: 'inputStart', 497 callback: (kbController: KeyboardController, textInputClient: TextInputClient) => void 498 ): void; 499 500 /** 501 * Unsubscribe 'inputStart' 502 * 503 * @param { 'inputStart' } type - indicates the type of subscribe event. 504 * @param { function } callback - optional, indicates the callback of off('inputStart'). 505 * @syscap SystemCapability.MiscServices.InputMethodFramework 506 * @since 8 507 */ 508 off( 509 type: 'inputStart', 510 callback?: (kbController: KeyboardController, textInputClient: TextInputClient) => void 511 ): void; 512 513 /** 514 * Subscribe 'keyboardShow'|'keyboardHide' 515 * 516 * @param { 'keyboardShow' | 'keyboardHide' } type - indicates the type of subscribe event. 517 * @param { function } callback - indicates the callback of on('keyboardShow'|'keyboardHide'). 518 * @syscap SystemCapability.MiscServices.InputMethodFramework 519 * @since 8 520 */ 521 on(type: 'keyboardShow' | 'keyboardHide', callback: () => void): void; 522 523 /** 524 * Unsubscribe 'keyboardShow'|'keyboardHide' 525 * 526 * @param { 'keyboardShow' | 'keyboardHide' } type - indicates the type of subscribe event. 527 * @param { function } [callback] - optional, indicates the callback of off('keyboardShow'|'keyboardHide'). 528 * @syscap SystemCapability.MiscServices.InputMethodFramework 529 * @since 8 530 */ 531 off(type: 'keyboardShow' | 'keyboardHide', callback?: () => void): void; 532 } 533 534 /** 535 * <p>Control events about IME.</p> 536 * <p>Events provided for IME to subscribe with callback function. When those events occur, the corresponding callback 537 * will be invoked.</p> 538 * 539 * @interface InputMethodAbility 540 * @syscap SystemCapability.MiscServices.InputMethodFramework 541 * @since 9 542 */ 543 interface InputMethodAbility { 544 /** 545 * Subscribe 'inputStart' event. 546 * 547 * @param { 'inputStart' } type - the type of subscribe event. 548 * @param { function } callback - the callback of on('inputStart'). 549 * @syscap SystemCapability.MiscServices.InputMethodFramework 550 * @since 9 551 */ 552 on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: InputClient) => void): void; 553 554 /** 555 * Unsubscribe 'inputStart' event. 556 * 557 * @param { 'inputStart' } type - the type of unsubscribe event. 558 * @param { function } [callback] - optional, the callback of off('inputStart'). 559 * @syscap SystemCapability.MiscServices.InputMethodFramework 560 * @since 9 561 */ 562 off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClient: InputClient) => void): void; 563 564 /** 565 * Subscribe 'inputStop'. 566 * 567 * @param { 'inputStop' } type - the type of subscribe event. 568 * @param { function } callback - the callback of on('inputStop'). 569 * @syscap SystemCapability.MiscServices.InputMethodFramework 570 * @since 9 571 */ 572 on(type: 'inputStop', callback: () => void): void; 573 574 /** 575 * Unsubscribe 'inputStop'. 576 * 577 * @param { 'inputStop' } type - the type of unsubscribe event. 578 * @param { function } callback - the callback of off('inputStop'). 579 * @syscap SystemCapability.MiscServices.InputMethodFramework 580 * @since 9 581 */ 582 off(type: 'inputStop', callback: () => void): void; 583 584 /** 585 * Subscribe 'setCallingWindow'. 586 * 587 * @param { 'setCallingWindow' } type - the type of subscribe event. 588 * @param { function } callback - the callback of on('setCallingWindow'). 589 * @syscap SystemCapability.MiscServices.InputMethodFramework 590 * @since 9 591 */ 592 on(type: 'setCallingWindow', callback: (wid: number) => void): void; 593 594 /** 595 * Unsubscribe 'setCallingWindow'. 596 * 597 * @param { 'setCallingWindow' } type - the type of unsubscribe event. 598 * @param { function } callback - the callback of off('setCallingWindow'). 599 * @syscap SystemCapability.MiscServices.InputMethodFramework 600 * @since 9 601 */ 602 off(type: 'setCallingWindow', callback: (wid: number) => void): void; 603 604 /** 605 * Subscribe 'keyboardShow'|'keyboardHide'. 606 * 607 * @param { 'keyboardShow' | 'keyboardHide' } type - the type of subscribe event. 608 * @param { function } callback - the callback of on('keyboardShow'|'keyboardHide'). 609 * @syscap SystemCapability.MiscServices.InputMethodFramework 610 * @since 9 611 */ 612 on(type: 'keyboardShow' | 'keyboardHide', callback: () => void): void; 613 614 /** 615 * Unsubscribe 'keyboardShow'|'keyboardHide'. 616 * 617 * @param { 'keyboardShow' | 'keyboardHide' } type - the type of unsubscribe event. 618 * @param { function } [callback] - the callback of off('keyboardShow'|'keyboardHide'). 619 * @syscap SystemCapability.MiscServices.InputMethodFramework 620 * @since 9 621 */ 622 off(type: 'keyboardShow' | 'keyboardHide', callback?: () => void): void; 623 624 /** 625 * Subscribe 'setSubtype'. 626 * 627 * @param { 'setSubtype' } type - the type of subscribe event. 628 * @param { function } callback - the callback of on('setSubtype'). 629 * @syscap SystemCapability.MiscServices.InputMethodFramework 630 * @since 9 631 */ 632 on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => void): void; 633 634 /** 635 * Unsubscribe 'setSubtype'. 636 * 637 * @param { 'setSubtype' } type - the type of subscribe event. 638 * @param { function } [callback] - the callback of off('setSubtype'). 639 * @syscap SystemCapability.MiscServices.InputMethodFramework 640 * @since 9 641 */ 642 off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void; 643 644 /** 645 * Subscribe 'securityModeChange' event. 646 * 647 * @param { 'securityModeChange' } type - the type of subscribe event. 648 * @param { Callback<SecurityMode> } callback - the callback of on('securityModeChange'). 649 * @syscap SystemCapability.MiscServices.InputMethodFramework 650 * @since 11 651 */ 652 on(type: 'securityModeChange', callback: Callback<SecurityMode>): void; 653 654 /** 655 * Unsubscribe 'securityModeChange' event. 656 * 657 * @param { 'securityModeChange' } type - the type of unsubscribe event. 658 * @param { Callback<SecurityMode> } [callback] - optional, the callback of off('securityModeChange'). 659 * @syscap SystemCapability.MiscServices.InputMethodFramework 660 * @since 11 661 */ 662 off(type: 'securityModeChange', callback?: Callback<SecurityMode>): void; 663 664 /** 665 * Subscribe 'privateCommand'.This function can only be called by default input method configured by system. 666 * 667 * @param { 'privateCommand' } type - indicates the type of subscribe event. 668 * @param { Callback<Record<string, CommandDataType>> } callback - indicates the callback of on('privateCommand'). 669 * @throws { BusinessError } 12800010 - not the preconfigured default input method. 670 * @syscap SystemCapability.MiscServices.InputMethodFramework 671 * @since 12 672 */ 673 on(type: 'privateCommand', callback: Callback<Record<string, CommandDataType>>): void; 674 675 /** 676 * Unsubscribe 'privateCommand'.This function can only be called by default input method configured by system. 677 * 678 * @param { 'privateCommand' } type - indicates the type of subscribe event. 679 * @param { Callback<Record<string, CommandDataType>> } [callback] - optional, 680 * indicates the callback of off('privateCommand'). 681 * @throws { BusinessError } 12800010 - not the preconfigured default input method. 682 * @syscap SystemCapability.MiscServices.InputMethodFramework 683 * @since 12 684 */ 685 off(type: 'privateCommand', callback?: Callback<Record<string, CommandDataType>>): void; 686 687 /** 688 * Subscribe 'callingDisplayDidChange' event. 689 * 690 * @param { 'callingDisplayDidChange' } type - indicates the type of subscribe event. 691 * @param { Callback<number> } callback - indicates the callback of on('callingDisplayDidChange'). 692 * @throws { BusinessError } 801 - capability not supported. 693 * @syscap SystemCapability.MiscServices.InputMethodFramework 694 * @since 18 695 */ 696 on(type: 'callingDisplayDidChange', callback: Callback<number>): void; 697 698 /** 699 * Unsubscribe 'callingDisplayDidChange' event. 700 * 701 * @param { 'callingDisplayDidChange' } type - indicates the type of subscribe event. 702 * @param { Callback<number> } [callback] - optional, indicates the callback of off('callingDisplayDidChange'). 703 * @syscap SystemCapability.MiscServices.InputMethodFramework 704 * @since 18 705 */ 706 off(type: 'callingDisplayDidChange', callback?: Callback<number>): void; 707 708 /** 709 * Subscribe 'discardTypingText'. 710 * 711 * @param { 'discardTypingText' } type - the type of subscribe event. 712 * @param { Callback<void> } callback - the callback of on('discardTypingText'). 713 * @syscap SystemCapability.MiscServices.InputMethodFramework 714 * @since 20 715 */ 716 on(type: 'discardTypingText', callback: Callback<void>): void; 717 718 /** 719 * Unsubscribe 'discardTypingText'. 720 * 721 * @param { 'discardTypingText' } type - the type of unsubscribe event. 722 * @param { Callback<void> } callback - the callback of off('discardTypingText'). 723 * @syscap SystemCapability.MiscServices.InputMethodFramework 724 * @since 20 725 */ 726 off(type: 'discardTypingText', callback?: Callback<void>): void; 727 728 /** 729 * Get input method's security mode. 730 * 731 * @returns { SecurityMode } return security mode. 732 * @throws { BusinessError } 12800004 - not an input method application. 733 * @syscap SystemCapability.MiscServices.InputMethodFramework 734 * @since 11 735 */ 736 getSecurityMode(): SecurityMode; 737 738 /** 739 * Creates a panel. 740 * <p>The system only allows one soft keyboard and one status bar to be created.</p> 741 * 742 * @param { BaseContext } ctx - indicates the context on which the window depends. 743 * @param { PanelInfo } info - the info of panel to be created. 744 * @param { AsyncCallback<Panel> } callback - the callback of createPanel. 745 * @throws { BusinessError } 401 - parameter error. Possible causes: 746 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 747 * @throws { BusinessError } 12800004 - not an input method application. 748 * @syscap SystemCapability.MiscServices.InputMethodFramework 749 * @since 10 750 */ 751 createPanel(ctx: BaseContext, info: PanelInfo, callback: AsyncCallback<Panel>): void; 752 753 /** 754 * Creates a panel. 755 * <p>The system only allows one soft keyboard and one status bar to be created.</p> 756 * 757 * @param { BaseContext } ctx - indicates the context on which the window depends. 758 * @param { PanelInfo } info - the info of panel to be created. 759 * @returns { Promise<Panel> } the promise returned by the function. 760 * @throws { BusinessError } 401 - parameter error. Possible causes: 761 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 762 * @throws { BusinessError } 12800004 - not an input method application. 763 * @syscap SystemCapability.MiscServices.InputMethodFramework 764 * @since 10 765 */ 766 createPanel(ctx: BaseContext, info: PanelInfo): Promise<Panel>; 767 768 /** 769 * Destroys a panel. 770 * 771 * @param { Panel } panel - to be destroyed. 772 * @param { AsyncCallback<void> } callback - the callback of destroyPanel. 773 * @throws { BusinessError } 401 - parameter error. Possible causes: 774 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 775 * @syscap SystemCapability.MiscServices.InputMethodFramework 776 * @since 10 777 */ 778 destroyPanel(panel: Panel, callback: AsyncCallback<void>): void; 779 780 /** 781 * Destroys a panel. 782 * 783 * @param { Panel } panel - to be destroyed. 784 * @returns { Promise<void> } the promise returned by the function. 785 * @throws { BusinessError } 401 - parameter error. Possible causes: 786 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 787 * @syscap SystemCapability.MiscServices.InputMethodFramework 788 * @since 10 789 */ 790 destroyPanel(panel: Panel): Promise<void>; 791 } 792 793 /** 794 * @interface TextInputClient 795 * @syscap SystemCapability.MiscServices.InputMethodFramework 796 * @since 8 797 * @deprecated since 9 798 * @useinstead inputMethodEngine#InputClient 799 */ 800 interface TextInputClient { 801 /** 802 * @param { number } action - action indicates the function of "enter" key. 803 * @param { AsyncCallback<boolean> } callback - the callback of sendKeyFunction. 804 * @syscap SystemCapability.MiscServices.InputMethodFramework 805 * @since 8 806 * @deprecated since 9 807 * @useinstead inputMethodEngine.InputClient#sendKeyFunction 808 */ 809 sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void; 810 811 /** 812 * @param { number } action - action indicates the function of "enter" key. 813 * @returns { Promise<boolean> } the promise returned by the function. 814 * @syscap SystemCapability.MiscServices.InputMethodFramework 815 * @since 8 816 * @deprecated since 9 817 * @useinstead inputMethodEngine.InputClient#sendKeyFunction 818 */ 819 sendKeyFunction(action: number): Promise<boolean>; 820 821 /** 822 * @param { number } length - length of text which will be deleted forward. 823 * @param { AsyncCallback<boolean> } callback - the callback of deleteForward. 824 * @syscap SystemCapability.MiscServices.InputMethodFramework 825 * @since 8 826 * @deprecated since 9 827 * @useinstead inputMethodEngine.InputClient#deleteForward 828 */ 829 deleteForward(length: number, callback: AsyncCallback<boolean>): void; 830 831 /** 832 * @param { number } length - length of text which will be deleted forward. 833 * @returns { Promise<boolean> } the promise returned by the function. 834 * @syscap SystemCapability.MiscServices.InputMethodFramework 835 * @since 8 836 * @deprecated since 9 837 * @useinstead inputMethodEngine.InputClient#deleteForward 838 */ 839 deleteForward(length: number): Promise<boolean>; 840 841 /** 842 * @param { number } length - length of text which will be deleted backward. 843 * @param { AsyncCallback<boolean> } callback - the callback of deleteBackward. 844 * @syscap SystemCapability.MiscServices.InputMethodFramework 845 * @since 8 846 * @deprecated since 9 847 * @useinstead inputMethodEngine.InputClient#deleteBackward 848 */ 849 deleteBackward(length: number, callback: AsyncCallback<boolean>): void; 850 851 /** 852 * @param { number } length - length of text which will be deleted backward. 853 * @returns { Promise<boolean> } the promise returned by the function. 854 * @syscap SystemCapability.MiscServices.InputMethodFramework 855 * @since 8 856 * @deprecated since 9 857 * @useinstead inputMethodEngine.InputClient#deleteBackward 858 */ 859 deleteBackward(length: number): Promise<boolean>; 860 861 /** 862 * @param { string } text - text which will be inserted. 863 * @param { AsyncCallback<boolean> } callback - the callback of insertText. 864 * @syscap SystemCapability.MiscServices.InputMethodFramework 865 * @since 8 866 * @deprecated since 9 867 * @useinstead inputMethodEngine.InputClient#insertText 868 */ 869 insertText(text: string, callback: AsyncCallback<boolean>): void; 870 871 /** 872 * @param { string } text - text which will be inserted. 873 * @returns { Promise<boolean> } the promise returned by the function 874 * @syscap SystemCapability.MiscServices.InputMethodFramework 875 * @since 8 876 * @deprecated since 9 877 * @useinstead inputMethodEngine.InputClient#insertText 878 */ 879 insertText(text: string): Promise<boolean>; 880 881 /** 882 * @param { number } length - the length of text which will be got. 883 * @param { AsyncCallback<string> } callback - the callback of getForward. 884 * @syscap SystemCapability.MiscServices.InputMethodFramework 885 * @since 8 886 * @deprecated since 9 887 * @useinstead inputMethodEngine.InputClient#getForward 888 */ 889 getForward(length: number, callback: AsyncCallback<string>): void; 890 891 /** 892 * @param { number } length - the length of text which will be got. 893 * @returns { Promise<string> } the promise returned by the function 894 * @syscap SystemCapability.MiscServices.InputMethodFramework 895 * @since 8 896 * @deprecated since 9 897 * @useinstead inputMethodEngine.InputClient#getForward 898 */ 899 getForward(length: number): Promise<string>; 900 901 /** 902 * @param { number } length - the length of text which will be got. 903 * @param { AsyncCallback<string> } callback - the callback of getBackward. 904 * @syscap SystemCapability.MiscServices.InputMethodFramework 905 * @since 8 906 * @deprecated since 9 907 * @useinstead inputMethodEngine.InputClient#getBackward 908 */ 909 getBackward(length: number, callback: AsyncCallback<string>): void; 910 911 /** 912 * @param { number } length - the length of text which will be got. 913 * @returns { Promise<string> } the promise returned by the function. 914 * @syscap SystemCapability.MiscServices.InputMethodFramework 915 * @since 8 916 * @deprecated since 9 917 * @useinstead inputMethodEngine.InputClient#getBackward 918 */ 919 getBackward(length: number): Promise<string>; 920 921 /** 922 * @param { AsyncCallback<EditorAttribute> } callback - the callback of getEditorAttribute. 923 * @syscap SystemCapability.MiscServices.InputMethodFramework 924 * @since 8 925 * @deprecated since 9 926 * @useinstead inputMethodEngine.InputClient#getEditorAttribute 927 */ 928 getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void; 929 930 /** 931 * @returns { Promise<EditorAttribute> } the promise returned by the function. 932 * @syscap SystemCapability.MiscServices.InputMethodFramework 933 * @since 8 934 * @deprecated since 9 935 * @useinstead inputMethodEngine.InputClient#getEditorAttribute 936 */ 937 getEditorAttribute(): Promise<EditorAttribute>; 938 } 939 940 /** 941 * Control events about Editor. 942 * 943 * @interface InputClient 944 * @syscap SystemCapability.MiscServices.InputMethodFramework 945 * @since 9 946 */ 947 interface InputClient { 948 /** 949 * Send the function of the key. 950 * 951 * @param { number } action - action indicates the function of "enter" key. 952 * @param { AsyncCallback<boolean> } callback - the callback of sendKeyFunction. 953 * @throws { BusinessError } 401 - parameter error. Possible causes: 954 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 955 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 956 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 957 * @syscap SystemCapability.MiscServices.InputMethodFramework 958 * @since 9 959 */ 960 sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void; 961 962 /** 963 * Send the function of the key. 964 * 965 * @param { number } action - action indicates the function of "enter" key. 966 * @returns { Promise<boolean> } the promise returned by the function. 967 * @throws { BusinessError } 401 - parameter error. Possible causes: 968 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 969 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 970 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 971 * @syscap SystemCapability.MiscServices.InputMethodFramework 972 * @since 9 973 */ 974 sendKeyFunction(action: number): Promise<boolean>; 975 976 /** 977 * Delete text forward. 978 * 979 * @param { number } length - length of text which will be deleted forward. It can't be less than 0. 980 * @param { AsyncCallback<boolean> } callback - the callback of deleteForward. 981 * @throws { BusinessError } 401 - parameter error. Possible causes: 982 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 983 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 984 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 985 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 986 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 987 * @syscap SystemCapability.MiscServices.InputMethodFramework 988 * @since 9 989 */ 990 deleteForward(length: number, callback: AsyncCallback<boolean>): void; 991 992 /** 993 * Delete text forward. 994 * 995 * @param { number } length - length of text which will be deleted forward. It can't be less than 0. 996 * @returns { Promise<boolean> } the promise returned by the function. 997 * @throws { BusinessError } 401 - parameter error. Possible causes: 998 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 999 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 1000 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 1001 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1002 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1003 * @syscap SystemCapability.MiscServices.InputMethodFramework 1004 * @since 9 1005 */ 1006 deleteForward(length: number): Promise<boolean>; 1007 1008 /** 1009 * Delete text forward. 1010 * 1011 * @param { number } length - length of text which will be deleted forward. It can't be less than 0. 1012 * @throws { BusinessError } 401 - parameter error. Possible causes: 1013 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1014 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 1015 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 1016 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1017 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1018 * @syscap SystemCapability.MiscServices.InputMethodFramework 1019 * @since 10 1020 */ 1021 deleteForwardSync(length: number): void; 1022 1023 /** 1024 * Delete text backward. 1025 * 1026 * @param { number } length - length of text which will be deleted backward. It can't be less than 0. 1027 * @param { AsyncCallback<boolean> } callback - the callback of deleteBackward. 1028 * @throws { BusinessError } 401 - parameter error. Possible causes: 1029 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1030 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 1031 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 1032 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1033 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1034 * @syscap SystemCapability.MiscServices.InputMethodFramework 1035 * @since 9 1036 */ 1037 deleteBackward(length: number, callback: AsyncCallback<boolean>): void; 1038 1039 /** 1040 * Delete text backward. 1041 * 1042 * @param { number } length - length of text which will be deleted backward. It can't be less than 0. 1043 * @returns { Promise<boolean> } the promise returned by the function. 1044 * @throws { BusinessError } 401 - parameter error. Possible causes: 1045 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1046 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 1047 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 1048 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1049 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1050 * @syscap SystemCapability.MiscServices.InputMethodFramework 1051 * @since 9 1052 */ 1053 deleteBackward(length: number): Promise<boolean>; 1054 1055 /** 1056 * Delete text backward. 1057 * 1058 * @param { number } length - length of text which will be deleted backward. It can't be less than 0. 1059 * @throws { BusinessError } 401 - parameter error. Possible causes: 1060 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1061 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 1062 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 1063 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1064 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1065 * @syscap SystemCapability.MiscServices.InputMethodFramework 1066 * @since 10 1067 */ 1068 deleteBackwardSync(length: number): void; 1069 1070 /** 1071 * Insert text into Editor. 1072 * 1073 * @param { string } text - text which will be inserted. 1074 * @param { AsyncCallback<boolean> } callback - the callback of insertText. 1075 * @throws { BusinessError } 401 - parameter error. Possible causes: 1076 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1077 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 1078 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 1079 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1080 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1081 * @syscap SystemCapability.MiscServices.InputMethodFramework 1082 * @since 9 1083 */ 1084 insertText(text: string, callback: AsyncCallback<boolean>): void; 1085 1086 /** 1087 * Insert text into Editor. 1088 * 1089 * @param { string } text - text which will be inserted. 1090 * @returns { Promise<boolean> } the promise returned by the function. 1091 * @throws { BusinessError } 401 - parameter error. Possible causes: 1092 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1093 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 1094 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 1095 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1096 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1097 * @syscap SystemCapability.MiscServices.InputMethodFramework 1098 * @since 9 1099 */ 1100 insertText(text: string): Promise<boolean>; 1101 1102 /** 1103 * Insert text into Editor. 1104 * 1105 * @param { string } text - text which will be inserted. 1106 * @throws { BusinessError } 401 - parameter error. Possible causes: 1107 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1108 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 1109 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 1110 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1111 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1112 * @syscap SystemCapability.MiscServices.InputMethodFramework 1113 * @since 10 1114 */ 1115 insertTextSync(text: string): void; 1116 1117 /** 1118 * Get the text before cursor. 1119 * 1120 * @param { number } length - the length of text which will be got. It can't be less than 0. 1121 * @param { AsyncCallback<string> } callback - the callback of getForward. 1122 * @throws { BusinessError } 401 - parameter error. Possible causes: 1123 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1124 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1125 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1126 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1127 * create InputMethodController object failed. 1128 * @syscap SystemCapability.MiscServices.InputMethodFramework 1129 * @since 9 1130 */ 1131 getForward(length: number, callback: AsyncCallback<string>): void; 1132 1133 /** 1134 * Get the text before cursor. 1135 * 1136 * @param { number } length - the length of text which will be got. It can't be less than 0. 1137 * @returns { Promise<string> } the promise returned by the function. 1138 * @throws { BusinessError } 401 - parameter error. Possible causes: 1139 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1140 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1141 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1142 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1143 * create InputMethodController object failed. 1144 * @syscap SystemCapability.MiscServices.InputMethodFramework 1145 * @since 9 1146 */ 1147 getForward(length: number): Promise<string>; 1148 1149 /** 1150 * Get the text before cursor. 1151 * 1152 * @param { number } length - the length of text which will be got. It can't be less than 0. 1153 * @returns { string } the text string before cursor. 1154 * @throws { BusinessError } 401 - parameter error. Possible causes: 1155 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1156 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1157 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1158 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1159 * create InputMethodController object failed. 1160 * @syscap SystemCapability.MiscServices.InputMethodFramework 1161 * @since 10 1162 */ 1163 getForwardSync(length: number): string; 1164 1165 /** 1166 * Get the text after cursor. 1167 * 1168 * @param { number } length - the length of text which will be got.It can't be less than 0. 1169 * @param { AsyncCallback<string> } callback - the callback of getBackward. 1170 * @throws { BusinessError } 401 - parameter error. Possible causes: 1171 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1172 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1173 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1174 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1175 * create InputMethodController object failed. 1176 * @syscap SystemCapability.MiscServices.InputMethodFramework 1177 * @since 9 1178 */ 1179 getBackward(length: number, callback: AsyncCallback<string>): void; 1180 1181 /** 1182 * Get the text after cursor. 1183 * 1184 * @param { number } length - the length of text which will be got.It can't be less than 0. 1185 * @returns { Promise<string> } the promise returned by the function. 1186 * @throws { BusinessError } 401 - parameter error. Possible causes: 1187 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1188 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1189 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1190 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1191 * create InputMethodController object failed. 1192 * @syscap SystemCapability.MiscServices.InputMethodFramework 1193 * @since 9 1194 */ 1195 getBackward(length: number): Promise<string>; 1196 1197 /** 1198 * Get the text after cursor. 1199 * 1200 * @param { number } length - the length of text which will be got. It can't be less than 0. 1201 * @returns { string } the text string after cursor. 1202 * @throws { BusinessError } 401 - parameter error. Possible causes: 1203 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1204 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1205 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1206 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1207 * create InputMethodController object failed. 1208 * @syscap SystemCapability.MiscServices.InputMethodFramework 1209 * @since 10 1210 */ 1211 getBackwardSync(length: number): string; 1212 1213 /** 1214 * Get attribute about editor. 1215 * 1216 * @param { AsyncCallback<EditorAttribute> } callback - the callback of getEditorAttribute. 1217 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1218 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1219 * @syscap SystemCapability.MiscServices.InputMethodFramework 1220 * @since 9 1221 */ 1222 getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void; 1223 1224 /** 1225 * Get attribute about editor. 1226 * 1227 * @returns { Promise<EditorAttribute> } the promise returned by the function. 1228 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1229 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1230 * @syscap SystemCapability.MiscServices.InputMethodFramework 1231 * @since 9 1232 */ 1233 getEditorAttribute(): Promise<EditorAttribute>; 1234 1235 /** 1236 * Get attribute about editor. 1237 * 1238 * @returns { EditorAttribute } the attribute of editor. 1239 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1240 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1241 * @syscap SystemCapability.MiscServices.InputMethodFramework 1242 * @since 10 1243 */ 1244 getEditorAttributeSync(): EditorAttribute; 1245 1246 /** 1247 * Move cursor from input method. 1248 * 1249 * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0. 1250 * @param { AsyncCallback<void> } callback - the callback of moveCursor. 1251 * @throws { BusinessError } 401 - parameter error. Possible causes: 1252 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1253 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1254 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1255 * @syscap SystemCapability.MiscServices.InputMethodFramework 1256 * @since 9 1257 */ 1258 moveCursor(direction: number, callback: AsyncCallback<void>): void; 1259 1260 /** 1261 * Move cursor from input method. 1262 * 1263 * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0. 1264 * @returns { Promise<void> } the promise returned by the function. 1265 * @throws { BusinessError } 401 - parameter error. Possible causes: 1266 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1267 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1268 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1269 * @syscap SystemCapability.MiscServices.InputMethodFramework 1270 * @since 9 1271 */ 1272 moveCursor(direction: number): Promise<void>; 1273 1274 /** 1275 * Move cursor from input method. 1276 * 1277 * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0. 1278 * @throws { BusinessError } 401 - parameter error. Possible causes: 1279 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1280 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1281 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1282 * @syscap SystemCapability.MiscServices.InputMethodFramework 1283 * @since 10 1284 */ 1285 moveCursorSync(direction: number): void; 1286 1287 /** 1288 * Select text in editor by range. 1289 * 1290 * @param { Range } range - indicates the range of selected text in editor. 1291 * @param { AsyncCallback<void> } callback - the callback of selectByRange. 1292 * @throws { BusinessError } 401 - parameter error. Possible causes: 1293 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1294 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1295 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1296 * @syscap SystemCapability.MiscServices.InputMethodFramework 1297 * @since 10 1298 */ 1299 selectByRange(range: Range, callback: AsyncCallback<void>): void; 1300 1301 /** 1302 * Select text in editor by range. 1303 * 1304 * @param { Range } range - indicates the range of selected text in editor. 1305 * @returns { Promise<void> } the promise returned by the function. 1306 * @throws { BusinessError } 401 - parameter error. Possible causes: 1307 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1308 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1309 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1310 * @syscap SystemCapability.MiscServices.InputMethodFramework 1311 * @since 10 1312 */ 1313 selectByRange(range: Range): Promise<void>; 1314 1315 /** 1316 * Select text in editor by range. 1317 * 1318 * @param { Range } range - indicates the range of selected text in editor. 1319 * @throws { BusinessError } 401 - parameter error. Possible causes: 1320 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1321 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1322 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1323 * @syscap SystemCapability.MiscServices.InputMethodFramework 1324 * @since 10 1325 */ 1326 selectByRangeSync(range: Range): void; 1327 1328 /** 1329 * Select text in editor by cursor movement. 1330 * 1331 * @param { Movement } movement - indicates the movement of cursor when selecting. 1332 * @param { AsyncCallback<void> } callback - the callback of selectByMovement. 1333 * @throws { BusinessError } 401 - parameter error. Possible causes: 1334 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1335 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1336 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1337 * @syscap SystemCapability.MiscServices.InputMethodFramework 1338 * @since 10 1339 */ 1340 selectByMovement(movement: Movement, callback: AsyncCallback<void>): void; 1341 1342 /** 1343 * Select text in editor by cursor movement. 1344 * 1345 * @param { Movement } movement - indicates the movement of cursor when selecting. 1346 * @returns { Promise<void> } the promise returned by the function. 1347 * @throws { BusinessError } 401 - parameter error. Possible causes: 1348 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1349 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1350 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1351 * @syscap SystemCapability.MiscServices.InputMethodFramework 1352 * @since 10 1353 */ 1354 selectByMovement(movement: Movement): Promise<void>; 1355 1356 /** 1357 * Select text in editor by cursor movement. 1358 * 1359 * @param { Movement } movement - indicates the movement of cursor when selecting. 1360 * @throws { BusinessError } 401 - parameter error. Possible causes: 1361 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1362 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1363 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1364 * @syscap SystemCapability.MiscServices.InputMethodFramework 1365 * @since 10 1366 */ 1367 selectByMovementSync(movement: Movement): void; 1368 1369 /** 1370 * Get the index number of text at cursor. 1371 * 1372 * @param { AsyncCallback<number> } callback - the callback of getTextIndexAtCursor, number represents the index 1373 * number of text at cursor. 1374 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1375 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1376 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1377 * create InputMethodController object failed. 1378 * @syscap SystemCapability.MiscServices.InputMethodFramework 1379 * @since 10 1380 */ 1381 getTextIndexAtCursor(callback: AsyncCallback<number>): void; 1382 1383 /** 1384 * Get the index number of text at cursor. 1385 * 1386 * @returns { Promise<number> } the promise returned by the function, number represents the index number of text 1387 * at cursor. 1388 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1389 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1390 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1391 * create InputMethodController object failed. 1392 * @syscap SystemCapability.MiscServices.InputMethodFramework 1393 * @since 10 1394 */ 1395 getTextIndexAtCursor(): Promise<number>; 1396 1397 /** 1398 * Get the index number of text at cursor. 1399 * 1400 * @returns { number } the index number of text at cursor. 1401 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1402 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1403 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1404 * create InputMethodController object failed. 1405 * @syscap SystemCapability.MiscServices.InputMethodFramework 1406 * @since 10 1407 */ 1408 getTextIndexAtCursorSync(): number; 1409 1410 /** 1411 * Send extend action code. 1412 * 1413 * @param { ExtendAction } action - action code which will be send. 1414 * @param { AsyncCallback<void> } callback - the callback of sendExtendAction. 1415 * @throws { BusinessError } 401 - parameter error. Possible causes: 1416 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types 1417 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1418 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1419 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1420 * create InputMethodController object failed. 1421 * @syscap SystemCapability.MiscServices.InputMethodFramework 1422 * @since 10 1423 */ 1424 sendExtendAction(action: ExtendAction, callback: AsyncCallback<void>): void; 1425 1426 /** 1427 * Send extend action code. 1428 * 1429 * @param { ExtendAction } action - action code which will be send. 1430 * @returns { Promise<void> } the promise returned by the function. 1431 * @throws { BusinessError } 401 - parameter error. Possible causes: 1432 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types 1433 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1434 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1435 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 1436 * create InputMethodController object failed. 1437 * @syscap SystemCapability.MiscServices.InputMethodFramework 1438 * @since 10 1439 */ 1440 sendExtendAction(action: ExtendAction): Promise<void>; 1441 1442 /** 1443 * Send private command.This function can only be called by default input method configured by system. 1444 * 1445 * @param { Record<string, CommandDataType> } commandData - command data which will be send.Max size 32KB. 1446 * @returns { Promise<void> } the promise returned by the function. 1447 * @throws { BusinessError } 401 - parameter error. Possible causes: 1448 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1449 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1450 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1451 * @throws { BusinessError } 12800010 - not the preconfigured default input method. 1452 * @syscap SystemCapability.MiscServices.InputMethodFramework 1453 * @since 12 1454 */ 1455 sendPrivateCommand(commandData: Record<string, CommandDataType>): Promise<void>; 1456 1457 /** 1458 * Get info of the calling window. 1459 * 1460 * @returns { Promise<WindowInfo> } the promise returned by the function. 1461 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1462 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1463 * @throws { BusinessError } 12800012 - the input method panel does not exist. 1464 * @throws { BusinessError } 12800013 - window manager service error. 1465 * @syscap SystemCapability.MiscServices.InputMethodFramework 1466 * @since 12 1467 */ 1468 getCallingWindowInfo(): Promise<WindowInfo>; 1469 1470 /** 1471 * Insert the provided text as preview text. 1472 * 1473 * @param { string } text - the text to be previewed. 1474 * @param { Range } range - the range of the text to be replaced by the preview text. 1475 * @returns { Promise<void> } the promise returned by the function. 1476 * @throws { BusinessError } 401 - parameter error. Possible causes: 1477 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1478 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1479 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1480 * @throws { BusinessError } 12800011 - text preview not supported. 1481 * @syscap SystemCapability.MiscServices.InputMethodFramework 1482 * @since 12 1483 */ 1484 setPreviewText(text: string, range: Range): Promise<void>; 1485 1486 /** 1487 * Insert the provided text as preview text. 1488 * 1489 * @param { string } text - the text to be previewed. 1490 * @param { Range } range - the range of the text to be replaced by the preview text. 1491 * @throws { BusinessError } 401 - parameter error. Possible causes: 1492 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1493 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1494 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1495 * @throws { BusinessError } 12800011 - text preview not supported. 1496 * @syscap SystemCapability.MiscServices.InputMethodFramework 1497 * @since 12 1498 */ 1499 setPreviewTextSync(text: string, range: Range): void; 1500 1501 /** 1502 * Finish the text preview. 1503 * 1504 * @returns { Promise<void> } the promise returned by the function. 1505 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1506 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1507 * @throws { BusinessError } 12800011 - text preview not supported. 1508 * @syscap SystemCapability.MiscServices.InputMethodFramework 1509 * @since 12 1510 */ 1511 finishTextPreview(): Promise<void>; 1512 1513 /** 1514 * Finish the text preview. 1515 * 1516 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1517 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1518 * @throws { BusinessError } 12800011 - text preview not supported. 1519 * @syscap SystemCapability.MiscServices.InputMethodFramework 1520 * @since 12 1521 */ 1522 finishTextPreviewSync(): void; 1523 1524 /** 1525 * Send message to edit box. 1526 * 1527 * @param { string } msgId - the identifier of the message. Max size is 256B. 1528 * @param { ?ArrayBuffer } [msgParam] - the param of the custom message. Max size is 128KB. 1529 * @returns { Promise<void> } the promise returned by the function. 1530 * @throws { BusinessError } 401 - parameter error. Possible causes: 1531 * 1. Incorrect parameter types. 2. Incorrect parameter length. 1532 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1533 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1534 * @throws { BusinessError } 12800009 - input method client detached. 1535 * @throws { BusinessError } 12800014 - the input method is in basic mode. 1536 * @throws { BusinessError } 12800015 - the other side does not accept the request. 1537 * @throws { BusinessError } 12800016 - input method client is not editable. 1538 * @syscap SystemCapability.MiscServices.InputMethodFramework 1539 * @since 15 1540 */ 1541 sendMessage(msgId: string, msgParam?: ArrayBuffer): Promise<void>; 1542 1543 /** 1544 * Start receiving message from edit box. 1545 * 1546 * @param { ?MessageHandler } [msgHandler] - optional, the handler of the custom message. 1547 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter types. 1548 * @syscap SystemCapability.MiscServices.InputMethodFramework 1549 * @since 15 1550 */ 1551 recvMessage(msgHandler?: MessageHandler): void; 1552 /** 1553 * Get input attachOptions. 1554 * 1555 * @returns { AttachOptions } return attach options. 1556 * @throws { BusinessError } 801 - Capability not supported. 1557 * @syscap SystemCapability.MiscServices.InputMethodFramework 1558 * @since 19 1559 */ 1560 /** 1561 * Get input attachOptions. 1562 * 1563 * @returns { AttachOptions } return attach options. 1564 * @syscap SystemCapability.MiscServices.InputMethodFramework 1565 * @since 20 1566 */ 1567 getAttachOptions(): AttachOptions; 1568 /** 1569 * Subscribe 'attachOptionsDidChange' event. 1570 * 1571 * @param { 'attachOptionsDidChange' } type - the type of subscribe event. 1572 * @param { Callback<AttachOptions> } callback - the callback of on('attachOptionsDidChange'). 1573 * @throws { BusinessError } 801 - Capability not supported. 1574 * @syscap SystemCapability.MiscServices.InputMethodFramework 1575 * @since 19 1576 */ 1577 /** 1578 * Subscribe 'attachOptionsDidChange' event. 1579 * 1580 * @param { 'attachOptionsDidChange' } type - the type of subscribe event. 1581 * @param { Callback<AttachOptions> } callback - the callback of on('attachOptionsDidChange'). 1582 * @syscap SystemCapability.MiscServices.InputMethodFramework 1583 * @since 20 1584 */ 1585 on(type: 'attachOptionsDidChange', callback: Callback<AttachOptions>): void; 1586 /** 1587 * Unsubscribe 'attachOptionsDidChange' event. 1588 * 1589 * @param { 'attachOptionsDidChange' } type - the type of unsubscribe event. 1590 * @param { Callback<AttachOptions> } [callback] - optional, the callback of off('attachOptionsDidChange'). 1591 * @syscap SystemCapability.MiscServices.InputMethodFramework 1592 * @since 19 1593 */ 1594 off(type: 'attachOptionsDidChange', callback?: Callback<AttachOptions>): void; 1595 } 1596 1597 /** 1598 * @interface KeyboardDelegate 1599 * @syscap SystemCapability.MiscServices.InputMethodFramework 1600 * @since 8 1601 */ 1602 interface KeyboardDelegate { 1603 /** 1604 * Subscribe key up or down event 1605 * 1606 * @param { 'keyDown' | 'keyUp' } type - indicates the type of subscribe event. 1607 * @param { function } callback - indicates the callback function of on('keyDown'|'keyUp'). 1608 * @syscap SystemCapability.MiscServices.InputMethodFramework 1609 * @since 8 1610 */ 1611 on(type: 'keyDown' | 'keyUp', callback: (event: KeyEvent) => boolean): void; 1612 1613 /** 1614 * Unsubscribe key up or down event 1615 * 1616 * @param { 'keyDown' | 'keyUp' } type - indicates the type of unsubscribe event. 1617 * @param { function } [callback] - optional, indicates the callback function of off('keyDown'|'keyUp'). 1618 * @syscap SystemCapability.MiscServices.InputMethodFramework 1619 * @since 8 1620 */ 1621 off(type: 'keyDown' | 'keyUp', callback?: (event: KeyEvent) => boolean): void; 1622 1623 /** 1624 * Subscribe key event. 1625 * 1626 * @param { 'keyEvent' } type - indicates the type of subscribe event. 1627 * @param { function } callback - indicates the callback function of on('keyEvent'). 1628 * If the key is processed by event subscriber, callback should be return true, else return false. 1629 * @syscap SystemCapability.MiscServices.InputMethodFramework 1630 * @since 10 1631 */ 1632 on(type: 'keyEvent', callback: (event: InputKeyEvent) => boolean): void; 1633 1634 /** 1635 * Unsubscribe key event. 1636 * 1637 * @param { 'keyEvent' } type - indicates the type of unsubscribe event. 1638 * @param { function } [callback] - optional, indicates the callback function of off('keyEvent'). 1639 * @syscap SystemCapability.MiscServices.InputMethodFramework 1640 * @since 10 1641 */ 1642 off(type: 'keyEvent', callback?: (event: InputKeyEvent) => boolean): void; 1643 1644 /** 1645 * Subscribe cursor context change 1646 * 1647 * @param { 'cursorContextChange' } type - indicates the type of subscribe event. 1648 * @param { function } callback - indicates the callback function of on('cursorContextChange'). 1649 * @syscap SystemCapability.MiscServices.InputMethodFramework 1650 * @since 8 1651 */ 1652 on(type: 'cursorContextChange', callback: (x: number, y: number, height: number) => void): void; 1653 1654 /** 1655 * Unsubscribe cursor context change 1656 * 1657 * @param { 'cursorContextChange' } type - indicates the type of unsubscribe event. 1658 * @param { function } [callback] - optional, indicates the callback function of off('cursorContextChange'). 1659 * @syscap SystemCapability.MiscServices.InputMethodFramework 1660 * @since 8 1661 */ 1662 off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void; 1663 1664 /** 1665 * Subscribe selection change 1666 * 1667 * @param { 'selectionChange' } type - indicates the type of subscribe event. 1668 * @param { function } callback - indicates the callback function 1669 * of on('selectionChange'). 1670 * @syscap SystemCapability.MiscServices.InputMethodFramework 1671 * @since 8 1672 */ 1673 on( 1674 type: 'selectionChange', 1675 callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void 1676 ): void; 1677 1678 /** 1679 * Unsubscribe selection change 1680 * 1681 * @param { 'selectionChange' } type - indicates the type of unsubscribe event. 1682 * @param { function } [callback] - optional, 1683 * indicates the callback function of off('selectionChange'). 1684 * @syscap SystemCapability.MiscServices.InputMethodFramework 1685 * @since 8 1686 */ 1687 off( 1688 type: 'selectionChange', 1689 callback?: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void 1690 ): void; 1691 1692 /** 1693 * Subscribe text change 1694 * 1695 * @param { 'textChange' } type - indicates the type of subscribe event. 1696 * @param { function } callback - indicates the callback function of on('textChange'). 1697 * @syscap SystemCapability.MiscServices.InputMethodFramework 1698 * @since 8 1699 */ 1700 on(type: 'textChange', callback: (text: string) => void): void; 1701 1702 /** 1703 * Unsubscribe text change 1704 * 1705 * @param { 'textChange' } type - indicates the type of unsubscribe event. 1706 * @param { function } [callback] - optional, indicates the callback function of off('textChange'). 1707 * @syscap SystemCapability.MiscServices.InputMethodFramework 1708 * @since 8 1709 */ 1710 off(type: 'textChange', callback?: (text: string) => void): void; 1711 1712 /** 1713 * Subscribe input text attribute change 1714 * 1715 * @param { 'editorAttributeChanged' } type - indicates the type of subscribe event. 1716 * @param { function } callback - indicates the callback function of on('editorAttributeChanged'). 1717 * @syscap SystemCapability.MiscServices.InputMethodFramework 1718 * @since 10 1719 */ 1720 on(type: 'editorAttributeChanged', callback: (attr: EditorAttribute) => void): void; 1721 1722 /** 1723 * Unsubscribe input text attribute change 1724 * 1725 * @param { 'editorAttributeChanged' } type - indicates the type of subscribe event. 1726 * @param { function } [callback] - indicates the callback function of off('editorAttributeChanged'). 1727 * @syscap SystemCapability.MiscServices.InputMethodFramework 1728 * @since 10 1729 */ 1730 off(type: 'editorAttributeChanged', callback?: (attr: EditorAttribute) => void): void; 1731 } 1732 1733 /** 1734 * Defines the immersive mode. 1735 * 1736 * @enum { number } 1737 * @syscap SystemCapability.MiscServices.InputMethodFramework 1738 * @since 15 1739 */ 1740 export enum ImmersiveMode { 1741 /** 1742 * Default immersive mode, the panel is not in immersive mode. 1743 * 1744 * @syscap SystemCapability.MiscServices.InputMethodFramework 1745 * @since 15 1746 */ 1747 NONE_IMMERSIVE = 0, 1748 1749 /** 1750 * Immersive mode. 1751 * 1752 * @syscap SystemCapability.MiscServices.InputMethodFramework 1753 * @since 15 1754 */ 1755 IMMERSIVE, 1756 1757 /** 1758 * Light immersive mode. 1759 * 1760 * @syscap SystemCapability.MiscServices.InputMethodFramework 1761 * @since 15 1762 */ 1763 LIGHT_IMMERSIVE, 1764 1765 /** 1766 * Dark immersive mode. 1767 * 1768 * @syscap SystemCapability.MiscServices.InputMethodFramework 1769 * @since 15 1770 */ 1771 DARK_IMMERSIVE 1772 } 1773 1774 /** 1775 * Gradient mode. 1776 * 1777 * @enum { number } 1778 * @syscap SystemCapability.MiscServices.InputMethodFramework 1779 * @since 20 1780 */ 1781 export enum GradientMode { 1782 /** 1783 * Disable gradient mode. 1784 * @syscap SystemCapability.MiscServices.InputMethodFramework 1785 * @since 20 1786 */ 1787 NONE = 0, 1788 /** 1789 * Linear gradient mode. 1790 * @syscap SystemCapability.MiscServices.InputMethodFramework 1791 * @since 20 1792 */ 1793 LINEAR_GRADIENT = 1, 1794 } 1795 1796 /** 1797 * Fluid light mode. 1798 * 1799 * @enum { number } 1800 * @syscap SystemCapability.MiscServices.InputMethodFramework 1801 * @systemapi 1802 * @since 20 1803 */ 1804 export enum FluidLightMode { 1805 /** 1806 * Disable fluid light mode. 1807 * @syscap SystemCapability.MiscServices.InputMethodFramework 1808 * @systemapi 1809 * @since 20 1810 */ 1811 NONE = 0, 1812 1813 /** 1814 * Background fluid light mode. 1815 * @syscap SystemCapability.MiscServices.InputMethodFramework 1816 * @systemapi 1817 * @since 20 1818 */ 1819 BACKGROUND_FLUID_LIGHT = 1, 1820 } 1821 1822 /** 1823 * Defines the immersive effect. 1824 * 1825 * @interface ImmersiveEffect 1826 * @syscap SystemCapability.MiscServices.InputMethodFramework 1827 * @since 20 1828 */ 1829 interface ImmersiveEffect { 1830 1831 /** 1832 * The height of the gradient effect. 1833 * 1834 * @type { number } 1835 * @syscap SystemCapability.MiscServices.InputMethodFramework 1836 * @since 20 1837 */ 1838 gradientHeight: number; 1839 1840 /** 1841 * Gradient mode. 1842 * 1843 * @type { GradientMode } 1844 * @syscap SystemCapability.MiscServices.InputMethodFramework 1845 * @since 20 1846 */ 1847 gradientMode: GradientMode; 1848 1849 /** 1850 * Fluid light mode. 1851 * 1852 * @type { ?FluidLightMode } 1853 * @syscap SystemCapability.MiscServices.InputMethodFramework 1854 * @systemapi 1855 * @since 20 1856 */ 1857 fluidLightMode?: FluidLightMode; 1858 } 1859 1860 /** 1861 * RequestKeyboardReason of input click. 1862 * 1863 * @enum { number } 1864 * @syscap SystemCapability.MiscServices.InputMethodFramework 1865 * @since 19 1866 */ 1867 export enum RequestKeyboardReason { 1868 /** 1869 * The request keyboard reason is NONE. 1870 * @syscap SystemCapability.MiscServices.InputMethodFramework 1871 * @since 19 1872 */ 1873 NONE = 0, 1874 /** 1875 * The request keyboard reason is MOUSE. 1876 * @syscap SystemCapability.MiscServices.InputMethodFramework 1877 * @since 19 1878 */ 1879 MOUSE = 1, 1880 /** 1881 * The request keyboard reason is TOUCH. 1882 * @syscap SystemCapability.MiscServices.InputMethodFramework 1883 * @since 19 1884 */ 1885 TOUCH = 2, 1886 /** 1887 * The request keyboard reason is OTHER. 1888 * @syscap SystemCapability.MiscServices.InputMethodFramework 1889 * @since 19 1890 */ 1891 OTHER = 20 1892 } 1893 1894 /** 1895 * A panel is a container used to hold soft keyboard, candidate list, or status bar. 1896 * 1897 * @interface Panel 1898 * @syscap SystemCapability.MiscServices.InputMethodFramework 1899 * @since 10 1900 */ 1901 interface Panel { 1902 /** 1903 * Sets ui content. 1904 * <p>When this method is executed successfully, the content of panel will be replaced.</p> 1905 * 1906 * @param { string } path - the path of ui content. 1907 * @param { AsyncCallback<void> } callback - the callback of setUiContent. 1908 * @throws { BusinessError } 401 - parameter error. Possible causes: 1909 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1910 * @syscap SystemCapability.MiscServices.InputMethodFramework 1911 * @since 10 1912 */ 1913 setUiContent(path: string, callback: AsyncCallback<void>): void; 1914 1915 /** 1916 * Sets ui content. 1917 * <p>When this method is executed successfully, the content of panel will be replaced.</p> 1918 * 1919 * @param { string } path - the path of ui content. 1920 * @returns { Promise<void> } the promise returned by the function. 1921 * @throws { BusinessError } 401 - parameter error. Possible causes: 1922 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1923 * @syscap SystemCapability.MiscServices.InputMethodFramework 1924 * @since 10 1925 */ 1926 setUiContent(path: string): Promise<void>; 1927 1928 /** 1929 * Sets ui content. 1930 * <p>When this method is executed successfully, the content of panel will be replaced.</p> 1931 * 1932 * @param { string } path - the path of ui content. 1933 * @param { LocalStorage } storage - the data object shared within the content instance loaded by the panel. 1934 * @param { AsyncCallback<void> } callback - the callback of setUiContent. 1935 * @throws { BusinessError } 401 - parameter error. Possible causes: 1936 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1937 * @syscap SystemCapability.MiscServices.InputMethodFramework 1938 * @since 10 1939 */ 1940 setUiContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void; 1941 1942 /** 1943 * Sets ui content. 1944 * <p>When this method is executed successfully, the content of panel will be replaced.</p> 1945 * 1946 * @param { string } path - the path of ui content. 1947 * @param { LocalStorage } storage - the data object shared within the content instance loaded by the panel. 1948 * @returns { Promise<void> } the promise returned by the function. 1949 * @throws { BusinessError } 401 - parameter error. Possible causes: 1950 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1951 * @syscap SystemCapability.MiscServices.InputMethodFramework 1952 * @since 10 1953 */ 1954 setUiContent(path: string, storage: LocalStorage): Promise<void>; 1955 1956 /** 1957 * Resizes a panel. 1958 * 1959 * @param { number } width - the new width of the panel. 1960 * @param { number } height - the new height of the panel. 1961 * @param { AsyncCallback<void> } callback - the callback of resize. 1962 * @throws { BusinessError } 401 - parameter error. Possible causes: 1963 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1964 * @syscap SystemCapability.MiscServices.InputMethodFramework 1965 * @since 10 1966 */ 1967 resize(width: number, height: number, callback: AsyncCallback<void>): void; 1968 1969 /** 1970 * Resizes a panel. 1971 * 1972 * @param { number } width - the new width of the panel. 1973 * @param { number } height - the new height of the panel. 1974 * @returns { Promise<void> } the promise returned by the function. 1975 * @throws { BusinessError } 401 - parameter error. Possible causes: 1976 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1977 * @syscap SystemCapability.MiscServices.InputMethodFramework 1978 * @since 10 1979 */ 1980 resize(width: number, height: number): Promise<void>; 1981 1982 /** 1983 * Moves a panel. 1984 * <p>It's unusable for SOFT_KEYBOARD panel with FLG_FIXED.</p> 1985 * 1986 * @param { number } x - the x-coordinate of the new position. 1987 * @param { number } y - the y-coordinate of the new position. 1988 * @param { AsyncCallback<void> } callback - the callback of moveTo. 1989 * @throws { BusinessError } 401 - parameter error. Possible causes: 1990 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1991 * @syscap SystemCapability.MiscServices.InputMethodFramework 1992 * @since 10 1993 */ 1994 moveTo(x: number, y: number, callback: AsyncCallback<void>): void; 1995 1996 /** 1997 * Moves a panel. 1998 * <p>It's unusable for SOFT_KEYBOARD panel with FLG_FIXED.</p> 1999 * 2000 * @param { number } x - the x-coordinate of the new position. 2001 * @param { number } y - the y-coordinate of the new position. 2002 * @returns { Promise<void> } the promise returned by the function. 2003 * @throws { BusinessError } 401 - parameter error. Possible causes: 2004 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2005 * @syscap SystemCapability.MiscServices.InputMethodFramework 2006 * @since 10 2007 */ 2008 moveTo(x: number, y: number): Promise<void>; 2009 2010 /** 2011 * Starts moving a panel. The panel starts moving when pressed with finger or mouse and stops moving when released. 2012 * <p>It's Only used for STATUS_BAR panel.</p> 2013 * 2014 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 2015 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 2016 * @throws { BusinessError } 12800013 - window manager service error. 2017 * @throws { BusinessError } 12800017 - invalid panel type or panel flag. 2018 * @syscap SystemCapability.MiscServices.InputMethodFramework 2019 * @since 15 2020 */ 2021 /** 2022 * Starts moving a panel. The panel starts moving when pressed with finger or mouse and stops moving when released. 2023 * <p>It's Only used for STATUS_BAR panel.</p> 2024 * 2025 * @throws { BusinessError } 801 - capability not supported. 2026 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 2027 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 2028 * @throws { BusinessError } 12800013 - window manager service error. 2029 * @throws { BusinessError } 12800017 - invalid panel type or panel flag. 2030 * @syscap SystemCapability.MiscServices.InputMethodFramework 2031 * @since 18 2032 */ 2033 /** 2034 * Starts moving a panel. The panel starts moving when pressed with finger or mouse and stops moving when released. 2035 * <p>It's only used for STATUS_BAR panel or SOFT_KEYBOARD panel with FLG_FLOATING or FLAG_CANDIDATE.</p> 2036 * 2037 * @throws { BusinessError } 801 - capability not supported. 2038 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 2039 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 2040 * @throws { BusinessError } 12800013 - window manager service error. 2041 * @throws { BusinessError } 12800017 - invalid panel type or panel flag. 2042 * @syscap SystemCapability.MiscServices.InputMethodFramework 2043 * @since 20 2044 */ 2045 startMoving(): void; 2046 2047 /** 2048 * Get the ID of the display where the input method panel is located. 2049 * 2050 * @returns { Promise<number> } the promise returned by the function. 2051 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 2052 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 2053 * @throws { BusinessError } 12800013 - window manager service error. 2054 * @syscap SystemCapability.MiscServices.InputMethodFramework 2055 * @since 15 2056 */ 2057 getDisplayId(): Promise<number>; 2058 2059 /** 2060 * Shows panel. 2061 * 2062 * @param { AsyncCallback<void> } callback - the callback of show. 2063 * @syscap SystemCapability.MiscServices.InputMethodFramework 2064 * @since 10 2065 */ 2066 show(callback: AsyncCallback<void>): void; 2067 2068 /** 2069 * Shows panel. 2070 * 2071 * @returns { Promise<void> } the promise returned by the function. 2072 * @syscap SystemCapability.MiscServices.InputMethodFramework 2073 * @since 10 2074 */ 2075 show(): Promise<void>; 2076 2077 /** 2078 * Hides panel. 2079 * 2080 * @param { AsyncCallback<void> } callback - the callback of hide. 2081 * @syscap SystemCapability.MiscServices.InputMethodFramework 2082 * @since 10 2083 */ 2084 hide(callback: AsyncCallback<void>): void; 2085 2086 /** 2087 * Hides panel. 2088 * 2089 * @returns { Promise<void> } the promise returned by the function. 2090 * @syscap SystemCapability.MiscServices.InputMethodFramework 2091 * @since 10 2092 */ 2093 hide(): Promise<void>; 2094 2095 /** 2096 * Registers panel show event. 2097 * <p>The "show" events are triggered when the panel is shown.</p> 2098 * 2099 * @param { 'show' } type - events type. 2100 * @param { function } callback - the callback will be called when events are triggered. 2101 * @syscap SystemCapability.MiscServices.InputMethodFramework 2102 * @since 10 2103 */ 2104 on(type: 'show', callback: () => void): void; 2105 2106 /** 2107 * Unregisters panel show event. 2108 * 2109 * @param { 'show' } type - events type. 2110 * @param { function } [callback] - the callback to Unregister. 2111 * @throws { BusinessError } 401 - parameter error. Possible causes: 2112 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 2113 * @syscap SystemCapability.MiscServices.InputMethodFramework 2114 * @since 10 2115 */ 2116 off(type: 'show', callback?: () => void): void; 2117 2118 /** 2119 * Registers panel hide event. 2120 * <p>The "hide" events are triggered when the panel is hidden.</p> 2121 * 2122 * @param { 'hide' } type - events type. 2123 * @param { function } callback - the callback will be called when events are triggered. 2124 * @syscap SystemCapability.MiscServices.InputMethodFramework 2125 * @since 10 2126 */ 2127 on(type: 'hide', callback: () => void): void; 2128 2129 /** 2130 * Unregisters panel hide event. 2131 * 2132 * @param { 'hide' } type - events type. 2133 * @param { function } [callback] - the callback to Unregister. 2134 * @throws { BusinessError } 401 - parameter error. Possible causes: 2135 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 2136 * @syscap SystemCapability.MiscServices.InputMethodFramework 2137 * @since 10 2138 */ 2139 off(type: 'hide', callback?: () => void): void; 2140 2141 /** 2142 * Changes panel flag. 2143 * <p>Before flag is changed, Developers should hide the panel.After that, developers can change the content, size, point of the panel 2144 * and show it again at appropriate opportunity.</p> 2145 * 2146 * @param { PanelFlag } flag - the callback of changeFlag. 2147 * @throws { BusinessError } 401 - parameter error. Possible causes: 2148 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 2149 * @syscap SystemCapability.MiscServices.InputMethodFramework 2150 * @since 10 2151 */ 2152 changeFlag(flag: PanelFlag): void; 2153 2154 /** 2155 * Sets ime panel private mode or not. 2156 * 2157 * @permission ohos.permission.PRIVACY_WINDOW 2158 * @param { boolean } isPrivacyMode - if the value is true, the privacy mode will be set, 2159 * otherwise the non-privacy mode will be set. 2160 * @throws { BusinessError } 201 - permissions check fails. 2161 * @throws { BusinessError } 401 - parameter error. Possible causes: 2162 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2163 * @syscap SystemCapability.MiscServices.InputMethodFramework 2164 * @since 11 2165 */ 2166 setPrivacyMode(isPrivacyMode: boolean): void; 2167 2168 /** 2169 * Adjust the rect of soft keyboard panel for landscape and portrait orientations. 2170 * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p> 2171 * 2172 * @param { PanelFlag } flag - panel flag. 2173 * @param { PanelRect } rect - panel rect. 2174 * @throws { BusinessError } 401 - parameter error. Possible causes: 2175 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 2176 * @throws { BusinessError } 12800013 - window manager service error. 2177 * @syscap SystemCapability.MiscServices.InputMethodFramework 2178 * @since 12 2179 */ 2180 adjustPanelRect(flag: PanelFlag, rect: PanelRect): void; 2181 2182 /** 2183 * Adjust the rect of soft keyboard panel for landscape and portrait orientations. 2184 * <p>It's only used for SOFT_KEYBOARD panel with fixed or floating flag.</p> 2185 * 2186 * @param { PanelFlag } flag - panel flag. 2187 * @param { EnhancedPanelRect } rect - panel rect. 2188 * @throws { BusinessError } 401 - parameter error. Possible causes: 2189 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 2190 * @throws { BusinessError } 12800013 - window manager service error. 2191 * @throws { BusinessError } 12800017 - invalid panel type or panel flag. 2192 * @syscap SystemCapability.MiscServices.InputMethodFramework 2193 * @since 15 2194 */ 2195 adjustPanelRect(flag: PanelFlag, rect: EnhancedPanelRect): void; 2196 2197 /** 2198 * <p>Update the region in the panel which accepts input events.</p> 2199 * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p> 2200 * 2201 * @param { Array<window.Rect> } inputRegion - region in the panel which accepts input event. The size of the array must range from 1 to 4. 2202 * @throws { BusinessError } 401 - parameter error. Possible causes: 2203 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 2204 * @throws { BusinessError } 12800013 - window manager service error. 2205 * @throws { BusinessError } 12800017 - invalid panel type or panel flag. 2206 * @syscap SystemCapability.MiscServices.InputMethodFramework 2207 * @since 15 2208 */ 2209 updateRegion(inputRegion: Array<window.Rect>): void; 2210 2211 /** 2212 * Subscribe 'sizeChange' event. 2213 * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p> 2214 * 2215 * @param { 'sizeChange' } type - the type of subscribe event. 2216 * @param { Callback<window.Size> } callback - the callback of on('sizeChange'). 2217 * @syscap SystemCapability.MiscServices.InputMethodFramework 2218 * @since 12 2219 */ 2220 /** 2221 * Subscribe 'sizeChange' event. 2222 * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p> 2223 * 2224 * @param { 'sizeChange' } type - the type of subscribe event. 2225 * @param { SizeChangeCallback } callback - the callback of on('sizeChange'). 2226 * @syscap SystemCapability.MiscServices.InputMethodFramework 2227 * @since 15 2228 */ 2229 on(type: 'sizeChange', callback: SizeChangeCallback): void; 2230 2231 /** 2232 * Unsubscribe 'sizeChange' event. 2233 * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p> 2234 * 2235 * @param { 'sizeChange' } type - the type of unsubscribe event. 2236 * @param { ?Callback<window.Size> } [callback] - optional, the callback of off('sizeChange'). 2237 * @syscap SystemCapability.MiscServices.InputMethodFramework 2238 * @since 12 2239 */ 2240 /** 2241 * Unsubscribe 'sizeChange' event. 2242 * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p> 2243 * 2244 * @param { 'sizeChange' } type - the type of unsubscribe event. 2245 * @param { ?SizeChangeCallback } [callback] - optional, the callback of off('sizeChange'). 2246 * @syscap SystemCapability.MiscServices.InputMethodFramework 2247 * @since 15 2248 */ 2249 off(type: 'sizeChange', callback?: SizeChangeCallback): void; 2250 2251 /** 2252 * Subscribe 'sizeUpdate' event. 2253 * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p> 2254 * 2255 * @param { 'sizeUpdate' } type - the type of subscribe event. 2256 * @param { SizeUpdateCallback } callback - the callback of on('sizeUpdate'). 2257 * @syscap SystemCapability.MiscServices.InputMethodFramework 2258 * @systemapi 2259 * @since 14 2260 */ 2261 on(type: 'sizeUpdate', callback: SizeUpdateCallback): void; 2262 2263 /** 2264 * Unsubscribe 'sizeUpdate' event. 2265 * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p> 2266 * 2267 * @param { 'sizeUpdate' } type - the type of unsubscribe event. 2268 * @param { ?SizeUpdateCallback } [callback] - optional, the callback of off('sizeUpdate'). 2269 * @syscap SystemCapability.MiscServices.InputMethodFramework 2270 * @systemapi 2271 * @since 14 2272 */ 2273 off(type: 'sizeUpdate', callback?: SizeUpdateCallback): void; 2274 2275 /** 2276 * Set immersive mode. 2277 * 2278 * @param { ImmersiveMode } mode - Immersive mode. 2279 * @throws { BusinessError } 401 - parameter error. Possible causes: 2280 * 1.Incorrect parameter types; 2.Parameter verification failed. 2281 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 2282 * 1.input method panel not created. 2.the input method application does not subscribe to related events. 2283 * @throws { BusinessError } 12800013 - window manager service error. 2284 * @syscap SystemCapability.MiscServices.InputMethodFramework 2285 * @since 15 2286 */ 2287 setImmersiveMode(mode: ImmersiveMode): void; 2288 2289 /** 2290 * Get immersive mode. 2291 * 2292 * @returns { ImmersiveMode } Immersive mode. 2293 * @syscap SystemCapability.MiscServices.InputMethodFramework 2294 * @since 15 2295 */ 2296 getImmersiveMode(): ImmersiveMode; 2297 2298 /** 2299 * Set immersive effect. 2300 * If a normal application uses the fluidLightMode property and sets it to a value other than NONE, 2301 * the interface will throw 202. 2302 * 2303 * @param { ImmersiveEffect } effect - immersive effect. 2304 * @throws { BusinessError } 801 - capability not supported. 2305 * @throws { BusinessError } 12800002 - input method engine error. Possible causes: 2306 * 1. input method panel not created. 2. the input method application does not subscribe to related events. 2307 * @throws { BusinessError } 12800013 - window manager service error. 2308 * @throws { BusinessError } 12800020 - invalid immersive effect. 2309 * 1. The gradient mode and the fluid light mode can only be used when the immersive mode is enabled. 2310 * 2. The fluid light mode can only be used when the gradient mode is enabled. 2311 * 3. When the gradient mode is not enabled, the gradient height can only be 0. 2312 * @throws { BusinessError } 12800021 - this operation is allowed only after adjustPanelRect or resize is called. 2313 * @syscap SystemCapability.MiscServices.InputMethodFramework 2314 * @since 20 2315 */ 2316 setImmersiveEffect(effect: ImmersiveEffect): void; 2317 /** 2318 * Set keep screen on. 2319 * This setting takes effect when the panel is showing and becomes invalid when the panel is hidden. 2320 * 2321 * @param { boolean } isKeepScreenOn - is keep screen on. 2322 * @returns { Promise<void> } the promise returned by the function. 2323 * @throws { BusinessError } 12800013 - window manager service error. 2324 * @syscap SystemCapability.MiscServices.InputMethodFramework 2325 * @since 20 2326 */ 2327 setKeepScreenOn(isKeepScreenOn: boolean): Promise<void>; 2328 } 2329 2330 /** 2331 * @interface EditorAttribute 2332 * @syscap SystemCapability.MiscServices.InputMethodFramework 2333 * @since 8 2334 */ 2335 interface EditorAttribute { 2336 /** 2337 * Editor's pattern 2338 * 2339 * @type { number } 2340 * @readonly 2341 * @syscap SystemCapability.MiscServices.InputMethodFramework 2342 * @since 8 2343 */ 2344 readonly inputPattern: number; 2345 2346 /** 2347 * Editor's key type 2348 * 2349 * @type { number } 2350 * @readonly 2351 * @syscap SystemCapability.MiscServices.InputMethodFramework 2352 * @since 8 2353 */ 2354 readonly enterKeyType: number; 2355 2356 /** 2357 * Indicates whether the editor supports the text preview. 2358 * 2359 * @type { boolean } 2360 * @syscap SystemCapability.MiscServices.InputMethodFramework 2361 * @since 12 2362 */ 2363 isTextPreviewSupported: boolean; 2364 2365 /** 2366 * Editor's bundle name. 2367 * 2368 * @type { ?string } 2369 * @readonly 2370 * @syscap SystemCapability.MiscServices.InputMethodFramework 2371 * @since 14 2372 */ 2373 readonly bundleName?: string; 2374 2375 /** 2376 * Immersive mode. 2377 * 2378 * @type { ?ImmersiveMode } 2379 * @readonly 2380 * @syscap SystemCapability.MiscServices.InputMethodFramework 2381 * @since 15 2382 */ 2383 readonly immersiveMode?: ImmersiveMode; 2384 2385 /** 2386 * Indicates the ID of the window where the edit box is located. 2387 * 2388 * @type { ?number } 2389 * @readonly 2390 * @syscap SystemCapability.MiscServices.InputMethodFramework 2391 * @since 18 2392 */ 2393 readonly windowId?: number; 2394 2395 /** 2396 * Indicates the ID of the display where the edit box is located. 2397 * 2398 * @type { ?number } 2399 * @readonly 2400 * @syscap SystemCapability.MiscServices.InputMethodFramework 2401 * @since 18 2402 */ 2403 readonly displayId?: number; 2404 2405 /** 2406 * Placeholder text in the edit box. 2407 * 2408 * @type { ?string } 2409 * @readonly 2410 * @syscap SystemCapability.MiscServices.InputMethodFramework 2411 * @since 20 2412 */ 2413 readonly placeholder?: string; 2414 2415 /** 2416 * The name of the ability where the edit box is located. 2417 * 2418 * @type { ?string } 2419 * @readonly 2420 * @syscap SystemCapability.MiscServices.InputMethodFramework 2421 * @since 20 2422 */ 2423 readonly abilityName?: string; 2424 2425 /** 2426 * Editor's capitalization mode. 2427 * 2428 * @type { ?CapitalizeMode } 2429 * @readonly 2430 * @syscap SystemCapability.MiscServices.InputMethodFramework 2431 * @since 20 2432 */ 2433 readonly capitalizeMode?: CapitalizeMode; 2434 2435 /** 2436 * Gradient mode. 2437 * 2438 * @type { ?GradientMode } 2439 * @readonly 2440 * @syscap SystemCapability.MiscServices.InputMethodFramework 2441 * @since 20 2442 */ 2443 readonly gradientMode?: GradientMode; 2444 2445 /** 2446 * Fluid light mode. 2447 * 2448 * @type { ?FluidLightMode } 2449 * @readonly 2450 * @syscap SystemCapability.MiscServices.InputMethodFramework 2451 * @systemapi 2452 * @since 20 2453 */ 2454 readonly fluidLightMode?: FluidLightMode; 2455 } 2456 2457 /** 2458 * @interface KeyEvent 2459 * @syscap SystemCapability.MiscServices.InputMethodFramework 2460 * @since 8 2461 */ 2462 interface KeyEvent { 2463 /** 2464 * Key code 2465 * 2466 * @type { number } 2467 * @readonly 2468 * @syscap SystemCapability.MiscServices.InputMethodFramework 2469 * @since 8 2470 */ 2471 readonly keyCode: number; 2472 2473 /** 2474 * Key action 2475 * 2476 * @type { number } 2477 * @readonly 2478 * @syscap SystemCapability.MiscServices.InputMethodFramework 2479 * @since 8 2480 */ 2481 readonly keyAction: number; 2482 } 2483 2484 /** 2485 * Enumerates the flags of panel 2486 * 2487 * @enum { number } 2488 * @syscap SystemCapability.MiscServices.InputMethodFramework 2489 * @since 10 2490 */ 2491 export enum PanelFlag { 2492 /** 2493 * Fixed style. 2494 * <p>It's provided for the panel with type of SOFT_KEYBOARD. 2495 * When the flag is set, the soft keyboard is fixed at the bottom of the screen.</p> 2496 * 2497 * @syscap SystemCapability.MiscServices.InputMethodFramework 2498 * @since 10 2499 */ 2500 FLG_FIXED = 0, 2501 2502 /** 2503 * Floating style. 2504 * <p>It's provided for the panel with type of SOFT_KEYBOARD. 2505 * When the flag is set, the soft keyboard is floating.</p> 2506 * 2507 * @syscap SystemCapability.MiscServices.InputMethodFramework 2508 * @since 10 2509 */ 2510 FLG_FLOATING, 2511 2512 /** 2513 * Candidate style. 2514 * <p>It's provided for the panel with type of SOFT_KEYBOARD. 2515 * When the flag is set, the soft keyboard is a candidate window which will show the possible characters when user types a input code. 2516 * Panel with candidate style will not be automatically shown or hidden by input method service. 2517 * Input method application developers are supposed to control the panel status on their own.</p> 2518 * 2519 * @syscap SystemCapability.MiscServices.InputMethodFramework 2520 * @since 15 2521 */ 2522 FLAG_CANDIDATE 2523 } 2524 2525 /** 2526 * <p>Panel types provided for input method applications.</p> 2527 * <p>Input method application developers should select the appropriate panel type according to the user scenario.</p> 2528 * 2529 * @enum { number } 2530 * @syscap SystemCapability.MiscServices.InputMethodFramework 2531 * @since 10 2532 */ 2533 export enum PanelType { 2534 /** 2535 * Panel for displaying a virtual software keyboard. 2536 * 2537 * @syscap SystemCapability.MiscServices.InputMethodFramework 2538 * @since 10 2539 */ 2540 SOFT_KEYBOARD = 0, 2541 2542 /** 2543 * Panel for displaying status bar. 2544 * 2545 * @syscap SystemCapability.MiscServices.InputMethodFramework 2546 * @since 10 2547 */ 2548 STATUS_BAR 2549 } 2550 2551 /** 2552 * Panel information. 2553 * 2554 * @typedef PanelInfo 2555 * @syscap SystemCapability.MiscServices.InputMethodFramework 2556 * @since 10 2557 */ 2558 export interface PanelInfo { 2559 /** 2560 * Panel type. 2561 * 2562 * @type { PanelType } 2563 * @syscap SystemCapability.MiscServices.InputMethodFramework 2564 * @since 10 2565 */ 2566 type: PanelType; 2567 2568 /** 2569 * <p>Flag of Panel.</p> 2570 * <p>Currently only using for SOFT_KEYBOARD panel.</p> 2571 * 2572 * @type { ?PanelFlag } 2573 * @default FLG_FIXED 2574 * @syscap SystemCapability.MiscServices.InputMethodFramework 2575 * @since 10 2576 */ 2577 flag?: PanelFlag; 2578 } 2579 2580 /** 2581 * Enumerates the moving direction of cursor 2582 * 2583 * @enum { number } 2584 * @syscap SystemCapability.MiscServices.InputMethodFramework 2585 * @since 10 2586 */ 2587 export enum Direction { 2588 /** 2589 * Cursor moves up 2590 * 2591 * @syscap SystemCapability.MiscServices.InputMethodFramework 2592 * @since 10 2593 */ 2594 CURSOR_UP = 1, 2595 2596 /** 2597 * Cursor moves down 2598 * 2599 * @syscap SystemCapability.MiscServices.InputMethodFramework 2600 * @since 10 2601 */ 2602 CURSOR_DOWN, 2603 2604 /** 2605 * Cursor moves left 2606 * 2607 * @syscap SystemCapability.MiscServices.InputMethodFramework 2608 * @since 10 2609 */ 2610 CURSOR_LEFT, 2611 2612 /** 2613 * Cursor moves right 2614 * 2615 * @syscap SystemCapability.MiscServices.InputMethodFramework 2616 * @since 10 2617 */ 2618 CURSOR_RIGHT 2619 } 2620 2621 /** 2622 * Enumerates the security mode. 2623 * 2624 * @enum { number } 2625 * @syscap SystemCapability.MiscServices.InputMethodFramework 2626 * @since 11 2627 */ 2628 export enum SecurityMode { 2629 /** 2630 * Basic security mode 2631 * 2632 * @syscap SystemCapability.MiscServices.InputMethodFramework 2633 * @since 11 2634 */ 2635 BASIC = 0, 2636 /** 2637 * Full security mode 2638 * 2639 * @syscap SystemCapability.MiscServices.InputMethodFramework 2640 * @since 11 2641 */ 2642 FULL 2643 } 2644 2645 /** 2646 * Range of selected text. 2647 * 2648 * @interface Range 2649 * @syscap SystemCapability.MiscServices.InputMethodFramework 2650 * @since 10 2651 */ 2652 export interface Range { 2653 /** 2654 * Indicates the index of the first character of the selected text. 2655 * 2656 * @type { number } 2657 * @syscap SystemCapability.MiscServices.InputMethodFramework 2658 * @since 10 2659 */ 2660 start: number; 2661 2662 /** 2663 * Indicates the index of the last character of the selected text. 2664 * 2665 * @type { number } 2666 * @syscap SystemCapability.MiscServices.InputMethodFramework 2667 * @since 10 2668 */ 2669 end: number; 2670 } 2671 2672 /** 2673 * Movement of cursor. 2674 * 2675 * @interface Movement 2676 * @syscap SystemCapability.MiscServices.InputMethodFramework 2677 * @since 10 2678 */ 2679 export interface Movement { 2680 /** 2681 * Indicates the direction of cursor movement 2682 * 2683 * @type { Direction } 2684 * @syscap SystemCapability.MiscServices.InputMethodFramework 2685 * @since 10 2686 */ 2687 direction: Direction; 2688 } 2689 2690 /** 2691 * Enumerates the extend action. 2692 * 2693 * @enum { number } 2694 * @syscap SystemCapability.MiscServices.InputMethodFramework 2695 * @since 10 2696 */ 2697 export enum ExtendAction { 2698 /** 2699 * Select all text. 2700 * 2701 * @syscap SystemCapability.MiscServices.InputMethodFramework 2702 * @since 10 2703 */ 2704 SELECT_ALL = 0, 2705 2706 /** 2707 * Cut selecting text. 2708 * 2709 * @syscap SystemCapability.MiscServices.InputMethodFramework 2710 * @since 10 2711 */ 2712 CUT = 3, 2713 2714 /** 2715 * Copy selecting text. 2716 * 2717 * @syscap SystemCapability.MiscServices.InputMethodFramework 2718 * @since 10 2719 */ 2720 COPY = 4, 2721 2722 /** 2723 * Paste from paste board. 2724 * 2725 * @syscap SystemCapability.MiscServices.InputMethodFramework 2726 * @since 10 2727 */ 2728 PASTE = 5 2729 } 2730 2731 /** 2732 * Window info. 2733 * 2734 * @interface WindowInfo 2735 * @syscap SystemCapability.MiscServices.InputMethodFramework 2736 * @since 12 2737 */ 2738 export interface WindowInfo { 2739 /** 2740 * Rectangle. 2741 * 2742 * @type { window.Rect } 2743 * @syscap SystemCapability.MiscServices.InputMethodFramework 2744 * @since 12 2745 */ 2746 rect: window.Rect; 2747 2748 /** 2749 * Window status. 2750 * 2751 * @type { window.WindowStatusType } 2752 * @syscap SystemCapability.MiscServices.InputMethodFramework 2753 * @since 12 2754 */ 2755 status: window.WindowStatusType; 2756 } 2757 2758 /** 2759 * Panel Rect. 2760 * 2761 * @interface PanelRect 2762 * @syscap SystemCapability.MiscServices.InputMethodFramework 2763 * @since 12 2764 */ 2765 export interface PanelRect { 2766 /** 2767 * Panel rect in landscape orientation. 2768 * 2769 * @type { window.Rect } 2770 * @syscap SystemCapability.MiscServices.InputMethodFramework 2771 * @since 12 2772 */ 2773 landscapeRect: window.Rect; 2774 2775 /** 2776 * Panel rect in portrait orientation. 2777 * 2778 * @type { window.Rect } 2779 * @syscap SystemCapability.MiscServices.InputMethodFramework 2780 * @since 12 2781 */ 2782 portraitRect: window.Rect; 2783 } 2784 2785 /** 2786 * <p>Custom message handler.</p> 2787 * <p>Implement this interface to respond to custem messages.</p> 2788 * 2789 * @interface MessageHandler 2790 * @syscap SystemCapability.MiscServices.InputMethodFramework 2791 * @since 15 2792 */ 2793 interface MessageHandler { 2794 /** 2795 * This method is called when a custom message is received. 2796 * 2797 * @param { string } msgId - the identifier of the message. 2798 * @param { ?ArrayBuffer } [msgParam] - the parameter of the custom message. 2799 * @syscap SystemCapability.MiscServices.InputMethodFramework 2800 * @since 15 2801 */ 2802 onMessage(msgId: string, msgParam?: ArrayBuffer): void; 2803 2804 /** 2805 * This method is called when a new message handler is set. 2806 * 2807 * @syscap SystemCapability.MiscServices.InputMethodFramework 2808 * @since 15 2809 */ 2810 onTerminated(): void; 2811 } 2812 2813 /** 2814 * Enhanced panel rect information. 2815 * 2816 * @interface EnhancedPanelRect 2817 * @syscap SystemCapability.MiscServices.InputMethodFramework 2818 * @since 15 2819 */ 2820 export interface EnhancedPanelRect { 2821 /** 2822 * <p>Panel rect in landscape orientation.</p> 2823 * <p>It must be filled when fullScreenMode is flase or not specified.</p> 2824 * 2825 * @type { ?window.Rect } 2826 * @syscap SystemCapability.MiscServices.InputMethodFramework 2827 * @since 15 2828 */ 2829 landscapeRect?: window.Rect; 2830 /** 2831 * <p>Panel rect in portrait orientation.</P> 2832 * <p>It must be filled when fullScreenMode is flase or not specified.</p> 2833 * 2834 * @type { ?window.Rect } 2835 * @syscap SystemCapability.MiscServices.InputMethodFramework 2836 * @since 15 2837 */ 2838 portraitRect?: window.Rect; 2839 /** 2840 * The distance between the top of the panel and the top of the avoidance area in landscape orientation. 2841 * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p> 2842 * 2843 * @type { ?number } 2844 * @default 0 2845 * @syscap SystemCapability.MiscServices.InputMethodFramework 2846 * @since 15 2847 */ 2848 landscapeAvoidY?: number; 2849 /** 2850 * <p>Region in the panel that accepts input events in landsacpe mode.</p> 2851 * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag. Max array size is 4.</p> 2852 * <p>Defaults to entire panel area if not specifed.</p> 2853 * 2854 * @type { ?Array<window.Rect> } 2855 * @syscap SystemCapability.MiscServices.InputMethodFramework 2856 * @since 15 2857 */ 2858 landscapeInputRegion?: Array<window.Rect>; 2859 /** 2860 * The distance between the top of the panel and the top of the avoidance area in portrait orientation. 2861 * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p> 2862 * 2863 * @type { ?number } 2864 * @default 0 2865 * @syscap SystemCapability.MiscServices.InputMethodFramework 2866 * @since 15 2867 */ 2868 portraitAvoidY?: number; 2869 /** 2870 * <p>Region in the panel that accepts input events in portrait mode.</p> 2871 * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag. Max array size is 4.</p> 2872 * <p>Defaults to entire panel area if not specifed.</p> 2873 * 2874 * @type { ?Array<window.Rect> } 2875 * @syscap SystemCapability.MiscServices.InputMethodFramework 2876 * @since 15 2877 */ 2878 portraitInputRegion?: Array<window.Rect>; 2879 /** 2880 * <p>Enter the full screen mode.</p> 2881 * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p> 2882 * 2883 * @type { ?boolean } 2884 * @default false 2885 * @syscap SystemCapability.MiscServices.InputMethodFramework 2886 * @since 15 2887 */ 2888 fullScreenMode?: boolean; 2889 } 2890 2891 /** 2892 * Keyboard area. 2893 * 2894 * @interface KeyboardArea 2895 * @syscap SystemCapability.MiscServices.InputMethodFramework 2896 * @since 15 2897 */ 2898 export interface KeyboardArea { 2899 /** 2900 * Top of the keyboard area in the panel. 2901 * 2902 * @type { number } 2903 * @syscap SystemCapability.MiscServices.InputMethodFramework 2904 * @since 15 2905 */ 2906 top: number; 2907 /** 2908 * Bottom of the keyboard area in the panel. 2909 * 2910 * @type { number } 2911 * @syscap SystemCapability.MiscServices.InputMethodFramework 2912 * @since 15 2913 */ 2914 bottom: number; 2915 /** 2916 * Left of the keyboard area in the panel. 2917 * 2918 * @type { number } 2919 * @syscap SystemCapability.MiscServices.InputMethodFramework 2920 * @since 15 2921 */ 2922 left: number; 2923 /** 2924 * Right of the keyboard area in the panel. 2925 * 2926 * @type { number } 2927 * @syscap SystemCapability.MiscServices.InputMethodFramework 2928 * @since 15 2929 */ 2930 right: number; 2931 } 2932 /** 2933 * Attach options. 2934 * 2935 * @interface AttachOptions 2936 * @syscap SystemCapability.MiscServices.InputMethodFramework 2937 * @since 19 2938 */ 2939 export interface AttachOptions { 2940 /** 2941 * The reason for request keyboard. 2942 * 2943 * @type { ?RequestKeyboardReason } 2944 * @syscap SystemCapability.MiscServices.InputMethodFramework 2945 * @since 19 2946 */ 2947 requestKeyboardReason?: RequestKeyboardReason; 2948 2949 /** 2950 * Is simple keyboard enabled. 2951 * 2952 * @type { ?boolean } 2953 * @syscap SystemCapability.MiscServices.InputMethodFramework 2954 * @since 20 2955 */ 2956 isSimpleKeyboardEnabled?: boolean; 2957 } 2958 2959 /** 2960 * Enumerates the capitalization mode. 2961 * 2962 * @enum { number } 2963 * @syscap SystemCapability.MiscServices.InputMethodFramework 2964 * @since 20 2965 */ 2966 export enum CapitalizeMode { 2967 /** 2968 * Capitalize nothing. 2969 * 2970 * @syscap SystemCapability.MiscServices.InputMethodFramework 2971 * @since 20 2972 */ 2973 NONE = 0, 2974 2975 /** 2976 * Capitalize the first letter of each sentence. 2977 * 2978 * @syscap SystemCapability.MiscServices.InputMethodFramework 2979 * @since 20 2980 */ 2981 SENTENCES, 2982 2983 /** 2984 * Capitalize the first letter of each word. 2985 * 2986 * @syscap SystemCapability.MiscServices.InputMethodFramework 2987 * @since 20 2988 */ 2989 WORDS, 2990 2991 /** 2992 * Capitalize each letter. 2993 * 2994 * @syscap SystemCapability.MiscServices.InputMethodFramework 2995 * @since 20 2996 */ 2997 CHARACTERS 2998 } 2999} 3000 3001export default inputMethodEngine; 3002