1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit IMEKit 19 */ 20import type { Callback, AsyncCallback } from './@ohos.base'; 21import type { ElementName } from './bundleManager/ElementName'; 22import InputMethodSubtype from './@ohos.InputMethodSubtype'; 23import type { PanelInfo } from './@ohos.inputMethod.Panel'; 24 25/** 26 * Input method 27 * 28 * @namespace inputMethod 29 * @syscap SystemCapability.MiscServices.InputMethodFramework 30 * @since 6 31 */ 32declare namespace inputMethod { 33 /** 34 * Keyboard max number 35 * 36 * @syscap SystemCapability.MiscServices.InputMethodFramework 37 * @since 8 38 */ 39 const MAX_TYPE_NUM: number; 40 41 /** 42 * Input method setting 43 * 44 * @returns { InputMethodSetting } the object of InputMethodSetting 45 * @syscap SystemCapability.MiscServices.InputMethodFramework 46 * @since 8 47 * @deprecated since 9 48 * @useinstead inputMethod#getSetting 49 */ 50 function getInputMethodSetting(): InputMethodSetting; 51 52 /** 53 * Input method controller 54 * 55 * @returns { InputMethodController } the object of InputMethodController. 56 * @syscap SystemCapability.MiscServices.InputMethodFramework 57 * @since 6 58 * @deprecated since 9 59 * @useinstead inputMethod#getController 60 */ 61 function getInputMethodController(): InputMethodController; 62 63 /** 64 * Input method setting 65 * 66 * @returns { InputMethodSetting } the object of InputMethodSetting. 67 * @throws { BusinessError } 12800007 - input method setter error. Possible cause: 68 * create InputMethodSetting object failed. 69 * @syscap SystemCapability.MiscServices.InputMethodFramework 70 * @since 9 71 */ 72 function getSetting(): InputMethodSetting; 73 74 /** 75 * Input method controller 76 * 77 * @returns { InputMethodController } the object of InputMethodController. 78 * @throws { BusinessError } 12800006 - input method controller error. Possible cause: 79 * create InputMethodController object failed. 80 * @syscap SystemCapability.MiscServices.InputMethodFramework 81 * @since 9 82 */ 83 function getController(): InputMethodController; 84 85 /** 86 * Get default input method 87 * 88 * @returns { InputMethodProperty } property of the default input method. 89 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 90 * a system error, such as null pointer, IPC exception. 91 * @syscap SystemCapability.MiscServices.InputMethodFramework 92 * @since 11 93 */ 94 function getDefaultInputMethod(): InputMethodProperty; 95 96 /** 97 * Get system input method config ability 98 * 99 * @returns { ElementName } the information of system input method config ability. 100 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 101 * a system error, such as null pointer, IPC exception. 102 * @syscap SystemCapability.MiscServices.InputMethodFramework 103 * @since 11 104 */ 105 function getSystemInputMethodConfigAbility(): ElementName; 106 107 /** 108 * Switch input method 109 * 110 * @permission ohos.permission.CONNECT_IME_ABILITY 111 * @param { InputMethodProperty } target - indicates the input method which will replace the current one. 112 * @param { AsyncCallback<boolean> } callback - the callback of switchInputMethod. 113 * @throws { BusinessError } 201 - permissions check fails. 114 * @throws { BusinessError } 401 - parameter error. Possible causes: 115 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 116 * @throws { BusinessError } 12800005 - configuration persistence error. 117 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 118 * a system error, such as null pointer, IPC exception. 119 * @syscap SystemCapability.MiscServices.InputMethodFramework 120 * @since 9 121 */ 122 /** 123 * Switch input method. The caller must be the current inputmethod. 124 * 125 * @param { InputMethodProperty } target - indicates the target input method. 126 * @param { AsyncCallback<boolean> } callback - the callback of switchInputMethod. 127 * @throws { BusinessError } 401 - parameter error. Possible causes: 128 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 129 * @throws { BusinessError } 12800005 - configuration persistence error. 130 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 131 * a system error, such as null pointer, IPC exception. 132 * @syscap SystemCapability.MiscServices.InputMethodFramework 133 * @since 11 134 */ 135 function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolean>): void; 136 137 /** 138 * Switch input method 139 * 140 * @permission ohos.permission.CONNECT_IME_ABILITY 141 * @param { InputMethodProperty } target - Indicates the input method which will replace the current one. 142 * @returns { Promise<boolean> } the promise returned by the function. 143 * @throws { BusinessError } 201 - permissions check fails. 144 * @throws { BusinessError } 401 - parameter error. Possible causes: 145 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 146 * @throws { BusinessError } 12800005 - configuration persistence error. 147 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 148 * a system error, such as null pointer, IPC exception. 149 * @syscap SystemCapability.MiscServices.InputMethodFramework 150 * @since 9 151 */ 152 /** 153 * Switch input method. The caller must be the current inputmethod. 154 * 155 * @param { InputMethodProperty } target - indicates the target input method. 156 * @returns { Promise<boolean> } the promise returned by the function. 157 * @throws { BusinessError } 401 - parameter error. Possible causes: 158 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 159 * @throws { BusinessError } 12800005 - configuration persistence error. 160 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 161 * a system error, such as null pointer, IPC exception. 162 * @syscap SystemCapability.MiscServices.InputMethodFramework 163 * @since 11 164 */ 165 function switchInputMethod(target: InputMethodProperty): Promise<boolean>; 166 167 /** 168 * Get current input method 169 * 170 * @returns { InputMethodProperty } the property of current inputmethod. 171 * @syscap SystemCapability.MiscServices.InputMethodFramework 172 * @since 9 173 */ 174 function getCurrentInputMethod(): InputMethodProperty; 175 176 /** 177 * Switch current input method subtype 178 * 179 * @permission ohos.permission.CONNECT_IME_ABILITY 180 * @param { InputMethodSubtype } target - Indicates the input method subtype which will replace the current one. 181 * @param { AsyncCallback<boolean> } callback - the callback of switchCurrentInputMethodSubtype. 182 * @throws { BusinessError } 201 - permissions check fails. 183 * @throws { BusinessError } 401 - parameter error. Possible causes: 184 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 185 * @throws { BusinessError } 12800005 - configuration persistence error. 186 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 187 * a system error, such as null pointer, IPC exception. 188 * @syscap SystemCapability.MiscServices.InputMethodFramework 189 * @since 9 190 */ 191 /** 192 * Switch current input method subtype, if this interface is invoked by the current IME, this permission is ignored. 193 * 194 * @permission ohos.permission.CONNECT_IME_ABILITY 195 * @param { InputMethodSubtype } target - Indicates the input method subtype which will replace the current one. 196 * @param { AsyncCallback<boolean> } callback - the callback of switchCurrentInputMethodSubtype. 197 * @throws { BusinessError } 201 - permissions check fails. 198 * @throws { BusinessError } 401 - parameter error. Possible causes: 199 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 200 * @throws { BusinessError } 12800005 - configuration persistence error. 201 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 202 * a system error, such as null pointer, IPC exception. 203 * @syscap SystemCapability.MiscServices.InputMethodFramework 204 * @since 10 205 */ 206 /** 207 * Switch current input method subtype. The caller must be the current inputmethod. 208 * 209 * @param { InputMethodSubtype } target - indicates the target input method subtype. 210 * @param { AsyncCallback<boolean> } callback - the callback of switchCurrentInputMethodSubtype. 211 * @throws { BusinessError } 401 - parameter error. Possible causes: 212 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 213 * @throws { BusinessError } 12800005 - configuration persistence error. 214 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 215 * a system error, such as null pointer, IPC exception. 216 * @syscap SystemCapability.MiscServices.InputMethodFramework 217 * @since 11 218 */ 219 function switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback<boolean>): void; 220 221 /** 222 * Switch current input method subtype 223 * 224 * @permission ohos.permission.CONNECT_IME_ABILITY 225 * @param { InputMethodSubtype } target - Indicates the input method subtype which will replace the current one. 226 * @returns { Promise<boolean> } the promise returned by the function. 227 * @throws { BusinessError } 201 - permissions check fails. 228 * @throws { BusinessError } 401 - parameter error. Possible causes: 229 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 230 * @throws { BusinessError } 12800005 - configuration persistence error. 231 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 232 * a system error, such as null pointer, IPC exception. 233 * @syscap SystemCapability.MiscServices.InputMethodFramework 234 * @since 9 235 */ 236 /** 237 * Switch current input method subtype, if this interface is invoked by the current IME, this permission is ignored. 238 * 239 * @permission ohos.permission.CONNECT_IME_ABILITY 240 * @param { InputMethodSubtype } target - Indicates the input method subtype which will replace the current one. 241 * @returns { Promise<boolean> } the promise returned by the function. 242 * @throws { BusinessError } 201 - permissions check fails. 243 * @throws { BusinessError } 401 - parameter error. Possible causes: 244 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 245 * @throws { BusinessError } 12800005 - configuration persistence error. 246 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 247 * a system error, such as null pointer, IPC exception. 248 * @syscap SystemCapability.MiscServices.InputMethodFramework 249 * @since 10 250 */ 251 /** 252 * Switch current input method subtype. The caller must be the current inputmethod. 253 * 254 * @param { InputMethodSubtype } target - indicates the target input method subtype. 255 * @returns { Promise<boolean> } the promise returned by the function. 256 * @throws { BusinessError } 401 - parameter error. Possible causes: 257 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 258 * @throws { BusinessError } 12800005 - configuration persistence error. 259 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 260 * a system error, such as null pointer, IPC exception. 261 * @syscap SystemCapability.MiscServices.InputMethodFramework 262 * @since 11 263 */ 264 function switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean>; 265 266 /** 267 * Get the current input method subtype 268 * 269 * @returns { InputMethodSubtype } the subtype of the current input method. 270 * @syscap SystemCapability.MiscServices.InputMethodFramework 271 * @since 9 272 */ 273 function getCurrentInputMethodSubtype(): InputMethodSubtype; 274 275 /** 276 * Switch input method and subtype. If the caller is an input method, it must be the current inputmethod. 277 * 278 * @permission ohos.permission.CONNECT_IME_ABILITY 279 * @param { InputMethodProperty } inputMethodProperty - Indicates the target input method. 280 * @param { InputMethodSubtype } inputMethodSubtype - Indicates the target input method subtype. 281 * @param { AsyncCallback<boolean> } callback - the callback of switchCurrentInputMethodAndSubtype. 282 * @throws { BusinessError } 201 - permissions check fails. 283 * @throws { BusinessError } 401 - parameter error. Possible causes: 284 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 285 * @throws { BusinessError } 12800005 - configuration persistence error. 286 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 287 * a system error, such as null pointer, IPC exception. 288 * @syscap SystemCapability.MiscServices.InputMethodFramework 289 * @since 9 290 */ 291 /** 292 * Switch input method and subtype. The caller must be the current inputmethod. 293 * 294 * @param { InputMethodProperty } inputMethodProperty - indicates the target input method. 295 * @param { InputMethodSubtype } inputMethodSubtype - indicates the target input method subtype. 296 * @param { AsyncCallback<boolean> } callback - the callback of switchCurrentInputMethodAndSubtype. 297 * @throws { BusinessError } 401 - parameter error. Possible causes: 298 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 299 * @throws { BusinessError } 12800005 - configuration persistence error. 300 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 301 * a system error, such as null pointer, IPC exception. 302 * @syscap SystemCapability.MiscServices.InputMethodFramework 303 * @since 11 304 */ 305 function switchCurrentInputMethodAndSubtype( 306 inputMethodProperty: InputMethodProperty, 307 inputMethodSubtype: InputMethodSubtype, 308 callback: AsyncCallback<boolean> 309 ): void; 310 311 /** 312 * Switch input method and subtype. If the caller is an input method, it must be the current inputmethod. 313 * 314 * @permission ohos.permission.CONNECT_IME_ABILITY 315 * @param { InputMethodProperty } inputMethodProperty - Indicates the target input method. 316 * @param { InputMethodSubtype } inputMethodSubtype - Indicates the target input method subtype. 317 * @returns { Promise<boolean> } the promise returned by the function. 318 * @throws { BusinessError } 201 - permissions check fails. 319 * @throws { BusinessError } 401 - parameter error. Possible causes: 320 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 321 * @throws { BusinessError } 12800005 - configuration persistence error. 322 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 323 * a system error, such as null pointer, IPC exception. 324 * @syscap SystemCapability.MiscServices.InputMethodFramework 325 * @since 9 326 */ 327 /** 328 * Switch input method and subtype. The caller must be the current inputmethod. 329 * 330 * @param { InputMethodProperty } inputMethodProperty - indicates the target input method. 331 * @param { InputMethodSubtype } inputMethodSubtype - indicates the target input method subtype. 332 * @returns { Promise<boolean> } the promise returned by the function. 333 * @throws { BusinessError } 401 - parameter error. Possible causes: 334 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 335 * @throws { BusinessError } 12800005 - configuration persistence error. 336 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 337 * a system error, such as null pointer, IPC exception. 338 * @syscap SystemCapability.MiscServices.InputMethodFramework 339 * @since 11 340 */ 341 function switchCurrentInputMethodAndSubtype( 342 inputMethodProperty: InputMethodProperty, 343 inputMethodSubtype: InputMethodSubtype 344 ): Promise<boolean>; 345 346 /** 347 * Switch input method and subtype 348 * 349 * @permission ohos.permission.CONNECT_IME_ABILITY 350 * @param { string } bundleName - indicates the bundleName of target input method. 351 * @param { string } [subtypeId] - indicates the id of the input method subtype. 352 * If the param is not set, switch to the target input method with a default subtype. 353 * @returns { Promise<void> } the promise returned by the function. 354 * @throws { BusinessError } 201 - permissions check fails. 355 * @throws { BusinessError } 202 - not system application. 356 * @throws { BusinessError } 401 - parameter error. Possible causes: 357 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 358 * @throws { BusinessError } 12800005 - configuration persistence error. 359 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 360 * a system error, such as null pointer, IPC exception. 361 * @syscap SystemCapability.MiscServices.InputMethodFramework 362 * @systemapi 363 * @since 11 364 */ 365 function switchInputMethod(bundleName: string, subtypeId?: string): Promise<void>; 366 367 /** 368 * Set simple keyboard mode. 369 * 370 * @param { boolean } enable - indicates enable simple keyboard or not. 371 * @syscap SystemCapability.MiscServices.InputMethodFramework 372 * @since 20 373 */ 374 function setSimpleKeyboardEnabled(enable: boolean): void; 375 376 /** 377 * @interface InputMethodSetting 378 * @syscap SystemCapability.MiscServices.InputMethodFramework 379 * @since 8 380 */ 381 interface InputMethodSetting { 382 /** 383 * Subscribe input method or subtype change. 384 * 385 * @param { 'imeChange' } type - Indicates the event type. 386 * @param { function } callback - the callback of 'imeChange' 387 * @syscap SystemCapability.MiscServices.InputMethodFramework 388 * @since 9 389 */ 390 on( 391 type: 'imeChange', 392 callback: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void 393 ): void; 394 395 /** 396 * Unsubscribe input method or subtype change. 397 * 398 * @param { 'imeChange' } type - Indicates the event type. 399 * @param { function } [callback] - the callback of 'imeChange', 400 * when subscriber unsubscribes all callback functions of event 'imeChange', this parameter can be left blank. 401 * @syscap SystemCapability.MiscServices.InputMethodFramework 402 * @since 9 403 */ 404 off( 405 type: 'imeChange', 406 callback?: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void 407 ): void; 408 409 /** 410 * Subscribes to input window show events. 411 * 412 * @param { 'imeShow' } type - Indicates the event type. 413 * @param { function } callback - the callback of 'imeShow'. 414 * @throws { BusinessError } 202 - not system application. 415 * @syscap SystemCapability.MiscServices.InputMethodFramework 416 * @systemapi 417 * @since 10 418 */ 419 on(type: 'imeShow', callback: (info: Array<InputWindowInfo>) => void): void; 420 421 /** 422 * Unsubscribe input window show event. 423 * 424 * @param { 'imeShow' } type - Indicates the event type. 425 * @param { function } [callback] - the callback of 'imeShow', 426 * when subscriber unsubscribes all callback functions of event 'imeShow', this parameter can be left blank. 427 * @syscap SystemCapability.MiscServices.InputMethodFramework 428 * @systemapi 429 * @since 10 430 */ 431 off(type: 'imeShow', callback?: (info: Array<InputWindowInfo>) => void): void; 432 433 /** 434 * Subscribes to input window hidden events. 435 * 436 * @param { 'imeHide' } type - Indicates the event type. 437 * @param { function } callback - the callback of 'imeHide'. 438 * @throws { BusinessError } 202 - not system application. 439 * @syscap SystemCapability.MiscServices.InputMethodFramework 440 * @systemapi 441 * @since 10 442 */ 443 on(type: 'imeHide', callback: (info: Array<InputWindowInfo>) => void): void; 444 445 /** 446 * Unsubscribe input window hide event. 447 * 448 * @param { 'imeHide' } type - Indicates the event type. 449 * @param { function } [callback] - the callback of 'imeHide', 450 * when subscriber unsubscribes all callback functions of event 'imeHide', this parameter can be left blank. 451 * @syscap SystemCapability.MiscServices.InputMethodFramework 452 * @systemapi 453 * @since 10 454 */ 455 off(type: 'imeHide', callback?: (info: Array<InputWindowInfo>) => void): void; 456 457 /** 458 * Query whether a panel with specified information is shown. 459 * 460 * @param { PanelInfo } panelInfo - the information of panel which is queried. 461 * @returns { boolean } 462 * If true, the panel being queried is shown. 463 * If false, the panel being queried is hidden. 464 * @throws { BusinessError } 202 - not system application. 465 * @throws { BusinessError } 401 - parameter error. Possible causes: 466 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 467 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 468 * a system error, such as null pointer, IPC exception. 469 * @syscap SystemCapability.MiscServices.InputMethodFramework 470 * @systemapi 471 * @since 11 472 */ 473 isPanelShown(panelInfo: PanelInfo): boolean; 474 475 /** 476 * List subtype of the specified input method. 477 * 478 * @param { InputMethodProperty } inputMethodProperty - the property of the specified inputmethod. 479 * @param { AsyncCallback<Array<InputMethodSubtype>> } callback - the callback of listInputMethodSubtype. 480 * @throws { BusinessError } 401 - parameter error. Possible causes: 481 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 482 * @throws { BusinessError } 12800001 - bundle manager error. 483 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 484 * a system error, such as null pointer, IPC exception. 485 * @syscap SystemCapability.MiscServices.InputMethodFramework 486 * @since 9 487 */ 488 listInputMethodSubtype( 489 inputMethodProperty: InputMethodProperty, 490 callback: AsyncCallback<Array<InputMethodSubtype>> 491 ): void; 492 493 /** 494 * List subtype of the specified input method. 495 * 496 * @param { InputMethodProperty } inputMethodProperty - Indicates the specified input method. 497 * @returns { Promise<Array<InputMethodSubtype>> } the promise returned by the function. 498 * @throws { BusinessError } 401 - parameter error. Possible causes: 499 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 500 * @throws { BusinessError } 12800001 - bundle manager error. 501 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 502 * a system error, such as null pointer, IPC exception. 503 * @syscap SystemCapability.MiscServices.InputMethodFramework 504 * @since 9 505 */ 506 listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Array<InputMethodSubtype>>; 507 508 /** 509 * List subtype of current input method 510 * 511 * @param { AsyncCallback<Array<InputMethodSubtype>> } callback - the callback of listCurrentInputMethodSubtype. 512 * @throws { BusinessError } 12800001 - bundle manager error. 513 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 514 * a system error, such as null pointer, IPC exception. 515 * @syscap SystemCapability.MiscServices.InputMethodFramework 516 * @since 9 517 */ 518 listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSubtype>>): void; 519 520 /** 521 * List subtype of current input method 522 * 523 * @returns { Promise<Array<InputMethodSubtype>> } the promise returned by the function. 524 * @throws { BusinessError } 12800001 - bundle manager error. 525 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 526 * a system error, such as null pointer, IPC exception. 527 * @syscap SystemCapability.MiscServices.InputMethodFramework 528 * @since 9 529 */ 530 listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>>; 531 532 /** 533 * List input methods 534 * 535 * @param { boolean } enable - 536 * If true, collect enabled input methods. 537 * If false, collect disabled input methods. 538 * @param { AsyncCallback<Array<InputMethodProperty>> } callback - the callback of getInputMethods. 539 * @throws { BusinessError } 401 - parameter error. Possible causes: 540 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 541 * @throws { BusinessError } 12800001 - bundle manager error. 542 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 543 * a system error, such as null pointer, IPC exception. 544 * @syscap SystemCapability.MiscServices.InputMethodFramework 545 * @since 9 546 */ 547 getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethodProperty>>): void; 548 549 /** 550 * List input methods 551 * 552 * @param { boolean } enable - 553 * If true, collect enabled input methods. 554 * If false, collect disabled input methods. 555 * @returns { Promise<Array<InputMethodProperty>> } the promise returned by the function. 556 * @throws { BusinessError } 401 - parameter error. Possible causes: 557 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 558 * @throws { BusinessError } 12800001 - bundle manager error. 559 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 560 * a system error, such as null pointer, IPC exception. 561 * @syscap SystemCapability.MiscServices.InputMethodFramework 562 * @since 9 563 */ 564 getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>; 565 566 /** 567 * List enabled or disabled input methods sync 568 * 569 * @param { boolean } enable - 570 * If true, collect enabled input methods. 571 * If false, collect disabled input methods. 572 * @returns { Array<InputMethodProperty> } the list of inputmethod. 573 * @throws { BusinessError } 401 - parameter error. Possible causes: 574 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 575 * @throws { BusinessError } 12800001 - bundle manager error. 576 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 577 * a system error, such as null pointer, IPC exception. 578 * @syscap SystemCapability.MiscServices.InputMethodFramework 579 * @since 11 580 */ 581 getInputMethodsSync(enable: boolean): Array<InputMethodProperty>; 582 583 /** 584 * List all input methods 585 * 586 * @param { AsyncCallback<Array<InputMethodProperty>> } callback - the callback of getInputMethods. 587 * @throws { BusinessError } 12800001 - bundle manager error. 588 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 589 * a system error, such as null pointer, IPC exception. 590 * @syscap SystemCapability.MiscServices.InputMethodFramework 591 * @since 11 592 */ 593 getAllInputMethods(callback: AsyncCallback<Array<InputMethodProperty>>): void; 594 595 /** 596 * List all input methods 597 * 598 * @returns { Promise<Array<InputMethodProperty>> } the promise returned by the function. 599 * @throws { BusinessError } 12800001 - bundle manager error. 600 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 601 * a system error, such as null pointer, IPC exception. 602 * @syscap SystemCapability.MiscServices.InputMethodFramework 603 * @since 11 604 */ 605 getAllInputMethods(): Promise<Array<InputMethodProperty>>; 606 607 /** 608 * List all input methods sync 609 * 610 * @returns { Array<InputMethodProperty> } the list of all inputmethod. 611 * @throws { BusinessError } 12800001 - bundle manager error. 612 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 613 * a system error, such as null pointer, IPC exception. 614 * @syscap SystemCapability.MiscServices.InputMethodFramework 615 * @since 11 616 */ 617 getAllInputMethodsSync(): Array<InputMethodProperty>; 618 619 /** 620 * @param { AsyncCallback<Array<InputMethodProperty>> } callback - the callback of listInputMethod. 621 * @syscap SystemCapability.MiscServices.InputMethodFramework 622 * @since 8 623 * @deprecated since 9 624 * @useinstead inputMethod.InputMethodSetting#getInputMethods 625 */ 626 listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>): void; 627 628 /** 629 * @returns { Promise<Array<InputMethodProperty>> } the promise returned by the function. 630 * @syscap SystemCapability.MiscServices.InputMethodFramework 631 * @since 8 632 * @deprecated since 9 633 * @useinstead inputMethod.InputMethodSetting#getInputMethods 634 */ 635 listInputMethod(): Promise<Array<InputMethodProperty>>; 636 637 /** 638 * Show input method setting extension dialog 639 * 640 * @param { AsyncCallback<boolean> } callback - the callback of showOptionalInputMethods. 641 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 642 * a system error, such as null pointer, IPC exception. 643 * @syscap SystemCapability.MiscServices.InputMethodFramework 644 * @since 9 645 * @deprecated since 18 646 */ 647 showOptionalInputMethods(callback: AsyncCallback<boolean>): void; 648 649 /** 650 * Show input method setting extension dialog 651 * 652 * @returns { Promise<boolean> } the promise returned by the function. 653 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 654 * a system error, such as null pointer, IPC exception. 655 * @syscap SystemCapability.MiscServices.InputMethodFramework 656 * @since 9 657 * @deprecated since 18 658 */ 659 showOptionalInputMethods(): Promise<boolean>; 660 661 /** 662 * @param { AsyncCallback<void> } callback - the callback of displayOptionalInputMethod. 663 * @syscap SystemCapability.MiscServices.InputMethodFramework 664 * @since 8 665 * @deprecated since 9 666 * @useinstead inputMethod.InputMethodSetting#showOptionalInputMethods 667 */ 668 displayOptionalInputMethod(callback: AsyncCallback<void>): void; 669 670 /** 671 * @returns { Promise<void> } the promise returned by the function. 672 * @syscap SystemCapability.MiscServices.InputMethodFramework 673 * @since 8 674 * @deprecated since 9 675 * @useinstead inputMethod.InputMethodSetting#showOptionalInputMethods 676 */ 677 displayOptionalInputMethod(): Promise<void>; 678 679 /** 680 * The input method application calls this interface to obtain its own enabled state. 681 * 682 * @returns { Promise<EnabledState> } the promise returned by the function. 683 * @throws { BusinessError } 12800004 - not an input method application. 684 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 685 * a system error, such as null pointer, IPC exception. 686 * @syscap SystemCapability.MiscServices.InputMethodFramework 687 * @since 15 688 */ 689 getInputMethodState(): Promise<EnabledState>; 690 691 /** 692 * 693 * Change inputmethod enabled status. 694 * 695 * @permission ohos.permission.CONNECT_IME_ABILITY 696 * @param { string } bundleName - Indicates the bundleName of the inputmethod. 697 * @param { string } extensionName - Indicates the extensionName of the inputmethod. 698 * @param { EnabledState } enabledState - Indicates the enabledState to be changed. 699 * @returns { Promise<void> } the promise returned by the function. 700 * @throws { BusinessError } 201 - permissions check fails. 701 * @throws { BusinessError } 202 - not system application. 702 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 703 * a system error, such as null pointer, IPC exception. 704 * @throws { BusinessError } 12800018 - the input method is not found. 705 * @throws { BusinessError } 12800019 - current operation cannot be applied to the preconfigured default input method. 706 * @syscap SystemCapability.MiscServices.InputMethodFramework 707 * @systemapi 708 * @since 20 709 */ 710 enableInputMethod(bundleName: string, extensionName: string, enabledState: EnabledState): Promise<void>; 711 } 712 713 /** 714 * @interface InputMethodController 715 * @syscap SystemCapability.MiscServices.InputMethodFramework 716 * @since 6 717 */ 718 interface InputMethodController { 719 /** 720 * Attach application to the input method service. 721 * 722 * @param { boolean } showKeyboard - show the keyboard or not when attach the input method. 723 * @param { TextConfig } textConfig - indicates the config of the textInput. 724 * @param { AsyncCallback<void> } callback - the callback of attach. 725 * @throws { BusinessError } 401 - parameter error. Possible causes: 726 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 727 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 728 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 729 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 730 * a system error, such as null pointer, IPC exception. 731 * @syscap SystemCapability.MiscServices.InputMethodFramework 732 * @since 10 733 */ 734 attach(showKeyboard: boolean, textConfig: TextConfig, callback: AsyncCallback<void>): void; 735 /** 736 * Attach application to the input method service. 737 * 738 * @param { boolean } showKeyboard - show the keyboard or not when attach the input method. 739 * @param { TextConfig } textConfig - indicates the config of the textInput. 740 * @returns { Promise<void> } the promise returned by the function. 741 * @throws { BusinessError } 401 - parameter error. Possible causes: 742 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 743 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 744 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 745 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 746 * a system error, such as null pointer, IPC exception. 747 * @syscap SystemCapability.MiscServices.InputMethodFramework 748 * @since 10 749 */ 750 attach(showKeyboard: boolean, textConfig: TextConfig): Promise<void>; 751 /** 752 * Attach application to the input method service. 753 * 754 * @param { boolean } showKeyboard - show the keyboard or not when attach the input method. 755 * @param { TextConfig } textConfig - indicates the config of the textInput. 756 * @param { RequestKeyboardReason } requestKeyboardReason - requestKeyboardReason of show the keyboard . 757 * @returns { Promise<void> } the promise returned by the function. 758 * @throws { BusinessError } 401 - parameter error. Possible causes: 759 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 760 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 761 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 762 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 763 * a system error, such as null pointer, IPC exception. 764 * @syscap SystemCapability.MiscServices.InputMethodFramework 765 * @since 15 766 */ 767 attach(showKeyboard: boolean, textConfig: TextConfig, requestKeyboardReason: RequestKeyboardReason): Promise<void>; 768 769 /** 770 * Discard the typing text 771 * 772 * @returns { Promise<void> } the promise returned by the function. 773 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 774 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 775 * @throws { BusinessError } 12800009 - input method client detached. 776 * @throws { BusinessError } 12800015 - the other side does not accept the request. 777 * @syscap SystemCapability.MiscServices.InputMethodFramework 778 * @since 20 779 */ 780 discardTypingText(): Promise<void>; 781 782 /** 783 * Show the text input and start typing. 784 * 785 * @param { AsyncCallback<void> } callback - the callback of showTextInput. 786 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 787 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 788 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 789 * a system error, such as null pointer, IPC exception. 790 * @throws { BusinessError } 12800009 - input method client detached. 791 * @syscap SystemCapability.MiscServices.InputMethodFramework 792 * @since 10 793 */ 794 showTextInput(callback: AsyncCallback<void>): void; 795 /** 796 * Show the text input and start typing. 797 * 798 * @returns { Promise<void> } the promise returned by the function. 799 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 800 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 801 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 802 * a system error, such as null pointer, IPC exception. 803 * @throws { BusinessError } 12800009 - input method client detached. 804 * @syscap SystemCapability.MiscServices.InputMethodFramework 805 * @since 10 806 */ 807 showTextInput(): Promise<void>; 808 /** 809 * Show the text input and start typing. 810 * 811 * @param { RequestKeyboardReason } requestKeyboardReason - requestKeyboardReason of show the keyboard . 812 * @returns { Promise<void> } the promise returned by the function. 813 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 814 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 815 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 816 * a system error, such as null pointer, IPC exception. 817 * @throws { BusinessError } 12800009 - input method client detached. 818 * @syscap SystemCapability.MiscServices.InputMethodFramework 819 * @since 15 820 */ 821 showTextInput(requestKeyboardReason: RequestKeyboardReason): Promise<void>; 822 /** 823 * Hide the text input and stop typing. 824 * 825 * @param { AsyncCallback<void> } callback - the callback of hideTextInput. 826 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 827 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 828 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 829 * a system error, such as null pointer, IPC exception. 830 * @throws { BusinessError } 12800009 - input method client detached. 831 * @syscap SystemCapability.MiscServices.InputMethodFramework 832 * @since 10 833 */ 834 hideTextInput(callback: AsyncCallback<void>): void; 835 836 /** 837 * Hide the text input and stop typing. 838 * 839 * @returns { Promise<void> } the promise returned by the function. 840 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 841 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 842 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 843 * a system error, such as null pointer, IPC exception. 844 * @throws { BusinessError } 12800009 - input method client detached. 845 * @syscap SystemCapability.MiscServices.InputMethodFramework 846 * @since 10 847 */ 848 hideTextInput(): Promise<void>; 849 850 /** 851 * Detach the applications from the input method manager service. 852 * 853 * @param { AsyncCallback<void> } callback - the callback of detach. 854 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 855 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 856 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 857 * a system error, such as null pointer, IPC exception. 858 * @syscap SystemCapability.MiscServices.InputMethodFramework 859 * @since 10 860 */ 861 detach(callback: AsyncCallback<void>): void; 862 863 /** 864 * Detach the applications from the input method manager service. 865 * 866 * @returns { Promise<void> } the promise returned by the function. 867 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 868 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 869 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 870 * a system error, such as null pointer, IPC exception. 871 * @syscap SystemCapability.MiscServices.InputMethodFramework 872 * @since 10 873 */ 874 detach(): Promise<void>; 875 876 /** 877 * Inform the system of the window ID of the application currently bound to the input method. 878 * After the correct setting, the window where the client is located can avoid the input method window. 879 * 880 * @param { number } windowId - the window ID of the application currently bound to the input method. 881 * @param { AsyncCallback<void> } callback - the callback of setCallingWindow. 882 * @throws { BusinessError } 401 - parameter error. Possible causes: 883 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 884 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 885 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 886 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 887 * a system error, such as null pointer, IPC exception. 888 * @throws { BusinessError } 12800009 - input method client detached. 889 * @syscap SystemCapability.MiscServices.InputMethodFramework 890 * @since 10 891 */ 892 setCallingWindow(windowId: number, callback: AsyncCallback<void>): void; 893 894 /** 895 * Inform the system of the window ID of the application currently bound to the input method. 896 * After the correct setting, the window where the client is located can avoid the input method window. 897 * 898 * @param { number } windowId - the window ID of the application currently bound to the input method. 899 * @returns { Promise<void> } the promise returned by the function. 900 * @throws { BusinessError } 401 - parameter error. Possible causes: 901 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 902 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 903 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 904 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 905 * a system error, such as null pointer, IPC exception. 906 * @throws { BusinessError } 12800009 - input method client detached. 907 * @syscap SystemCapability.MiscServices.InputMethodFramework 908 * @since 10 909 */ 910 setCallingWindow(windowId: number): Promise<void>; 911 912 /** 913 * Update Cursor and notify the input method that the current application cursor has changed. 914 * 915 * @param { CursorInfo } cursorInfo - the CursorInfo object. 916 * @param { AsyncCallback<void> } callback - the callback of updateCursor. 917 * @throws { BusinessError } 401 - parameter error. Possible causes: 918 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 919 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 920 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 921 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 922 * a system error, such as null pointer, IPC exception. 923 * @throws { BusinessError } 12800009 - input method client detached. 924 * @syscap SystemCapability.MiscServices.InputMethodFramework 925 * @since 10 926 */ 927 updateCursor(cursorInfo: CursorInfo, callback: AsyncCallback<void>): void; 928 929 /** 930 * Update Cursor and notify the input method that the current application cursor has changed. 931 * 932 * @param { CursorInfo } cursorInfo - the CursorInfo object. 933 * @returns { Promise<void> } the promise returned by the function. 934 * @throws { BusinessError } 401 - parameter error. Possible causes: 935 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 936 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 937 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 938 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 939 * a system error, such as null pointer, IPC exception. 940 * @throws { BusinessError } 12800009 - input method client detached. 941 * @syscap SystemCapability.MiscServices.InputMethodFramework 942 * @since 10 943 */ 944 updateCursor(cursorInfo: CursorInfo): Promise<void>; 945 946 /** 947 * Notify the input method the selected text and the selection range of the current application text has changed. 948 * 949 * @param { string } text - the whole input text. 950 * @param { number } start - start position of selected text. 951 * @param { number } end - end position of selected text. 952 * @param { AsyncCallback<void> } callback - the callback of changeSelection. 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 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 958 * a system error, such as null pointer, IPC exception. 959 * @throws { BusinessError } 12800009 - input method client detached. 960 * @syscap SystemCapability.MiscServices.InputMethodFramework 961 * @since 10 962 */ 963 changeSelection(text: string, start: number, end: number, callback: AsyncCallback<void>): void; 964 965 /** 966 * Notify the input method the selected text and the selection range of the current application text has changed. 967 * 968 * @param { string } text - the selected text. 969 * @param { number } start - start position of selected text. 970 * @param { number } end - end position of selected text. 971 * @returns { Promise<void> } the promise returned by the function. 972 * @throws { BusinessError } 401 - parameter error. Possible causes: 973 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 974 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 975 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 976 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 977 * a system error, such as null pointer, IPC exception. 978 * @throws { BusinessError } 12800009 - input method client detached. 979 * @syscap SystemCapability.MiscServices.InputMethodFramework 980 * @since 10 981 */ 982 changeSelection(text: string, start: number, end: number): Promise<void>; 983 984 /** 985 * Update InputAttribute information of input text. 986 * 987 * @param { InputAttribute } attribute - the InputAttribute object. 988 * @param { AsyncCallback<void> } callback - the callback of updateAttribute. 989 * @throws { BusinessError } 401 - parameter error. Possible causes: 990 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 991 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 992 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 993 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 994 * a system error, such as null pointer, IPC exception. 995 * @throws { BusinessError } 12800009 - input method client detached. 996 * @syscap SystemCapability.MiscServices.InputMethodFramework 997 * @since 10 998 */ 999 updateAttribute(attribute: InputAttribute, callback: AsyncCallback<void>): void; 1000 1001 /** 1002 * Update InputAttribute information of input text. 1003 * 1004 * @param { InputAttribute } attribute - the InputAttribute object. 1005 * @returns { Promise<void> } the promise returned by the function. 1006 * @throws { BusinessError } 401 - parameter error. Possible causes: 1007 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1008 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1009 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1010 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 1011 * a system error, such as null pointer, IPC exception. 1012 * @throws { BusinessError } 12800009 - input method client detached. 1013 * @syscap SystemCapability.MiscServices.InputMethodFramework 1014 * @since 10 1015 */ 1016 updateAttribute(attribute: InputAttribute): Promise<void>; 1017 /** 1018 * Stop input session 1019 * 1020 * @param { AsyncCallback<boolean> } callback - the callback of stopInputSession. 1021 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1022 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1023 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 1024 * a system error, such as null pointer, IPC exception. 1025 * @syscap SystemCapability.MiscServices.InputMethodFramework 1026 * @since 9 1027 */ 1028 stopInputSession(callback: AsyncCallback<boolean>): void; 1029 1030 /** 1031 * Stop input session 1032 * 1033 * @returns { Promise<boolean> } the promise returned by the function. 1034 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1035 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1036 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 1037 * a system error, such as null pointer, IPC exception. 1038 * @syscap SystemCapability.MiscServices.InputMethodFramework 1039 * @since 9 1040 */ 1041 stopInputSession(): Promise<boolean>; 1042 1043 /** 1044 * Stop input 1045 * 1046 * @param { AsyncCallback<boolean> } callback - the callback of stopInput. 1047 * @syscap SystemCapability.MiscServices.InputMethodFramework 1048 * @since 6 1049 * @deprecated since 9 1050 * @useinstead inputMethod.InputMethodController#stopInputSession 1051 */ 1052 stopInput(callback: AsyncCallback<boolean>): void; 1053 1054 /** 1055 * Stop input 1056 * 1057 * @returns { Promise<boolean> } the promise returned by the function. 1058 * @syscap SystemCapability.MiscServices.InputMethodFramework 1059 * @since 6 1060 * @deprecated since 9 1061 * @useinstead inputMethod.InputMethodController#stopInputSession 1062 */ 1063 stopInput(): Promise<boolean>; 1064 1065 /** 1066 * Show soft keyboard. 1067 * This API can be called only by system applications. 1068 * 1069 * @permission ohos.permission.CONNECT_IME_ABILITY 1070 * @param { AsyncCallback<void> } callback - the callback of showSoftKeyboard. 1071 * @throws { BusinessError } 201 - permissions check fails. 1072 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1073 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1074 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 1075 * a system error, such as null pointer, IPC exception. 1076 * @syscap SystemCapability.MiscServices.InputMethodFramework 1077 * @since 9 1078 */ 1079 showSoftKeyboard(callback: AsyncCallback<void>): void; 1080 1081 /** 1082 * Show soft keyboard. 1083 * This API can be called only by system applications. 1084 * 1085 * @permission ohos.permission.CONNECT_IME_ABILITY 1086 * @returns { Promise<void> } the promise returned by the function. 1087 * @throws { BusinessError } 201 - permissions check fails. 1088 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1089 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1090 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 1091 * a system error, such as null pointer, IPC exception. 1092 * @syscap SystemCapability.MiscServices.InputMethodFramework 1093 * @since 9 1094 */ 1095 showSoftKeyboard(): Promise<void>; 1096 1097 /** 1098 * Hide soft keyboard. 1099 * This API can be called only by system applications. 1100 * 1101 * @permission ohos.permission.CONNECT_IME_ABILITY 1102 * @param { AsyncCallback<void> } callback - the callback of hideSoftKeyboard. 1103 * @throws { BusinessError } 201 - permissions check fails. 1104 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1105 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1106 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 1107 * a system error, such as null pointer, IPC exception. 1108 * @syscap SystemCapability.MiscServices.InputMethodFramework 1109 * @since 9 1110 */ 1111 hideSoftKeyboard(callback: AsyncCallback<void>): void; 1112 1113 /** 1114 * Hide soft keyboard. 1115 * This API can be called only by system applications. 1116 * 1117 * @permission ohos.permission.CONNECT_IME_ABILITY 1118 * @returns { Promise<void> } the promise returned by the function. 1119 * @throws { BusinessError } 201 - permissions check fails. 1120 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1121 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1122 * @throws { BusinessError } 12800008 - input method manager service error. Possible cause: 1123 * a system error, such as null pointer, IPC exception. 1124 * @syscap SystemCapability.MiscServices.InputMethodFramework 1125 * @since 9 1126 */ 1127 hideSoftKeyboard(): Promise<void>; 1128 1129 /** 1130 * Send message to input method. 1131 * 1132 * @param { string } msgId - the identifier of the message. Max size is 256B. 1133 * @param { ?ArrayBuffer } [msgParam] - the param of the custom message. Max size is 128KB. 1134 * @returns { Promise<void> } the promise returned by the function. 1135 * @throws { BusinessError } 401 - parameter error. Possible causes: 1136 * 1. Incorrect parameter types. 2. Incorrect parameter length. 1137 * @throws { BusinessError } 12800003 - input method client error. Possible causes: 1138 * 1.the edit box is not focused. 2.no edit box is bound to current input method application. 1139 * @throws { BusinessError } 12800009 - input method client detached. 1140 * @throws { BusinessError } 12800014 - the input method is in basic mode. 1141 * @throws { BusinessError } 12800015 - the other side does not accept the request. 1142 * @throws { BusinessError } 12800016 - input method client is not editable. 1143 * @syscap SystemCapability.MiscServices.InputMethodFramework 1144 * @since 15 1145 */ 1146 sendMessage(msgId: string, msgParam?: ArrayBuffer): Promise<void>; 1147 1148 /** 1149 * Start receiving message from input method. 1150 * 1151 * @param { ?MessageHandler } [msgHandler] - optional, the handler of the custom message. 1152 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter types. 1153 * @syscap SystemCapability.MiscServices.InputMethodFramework 1154 * @since 15 1155 */ 1156 recvMessage(msgHandler?: MessageHandler): void; 1157 1158 /** 1159 * Register a callback and when IME sends select event with range of selection, 1160 * the callback will be invoked. 1161 * 1162 * @param { 'selectByRange' } type - event type, fixed as 'selectByRange'. 1163 * @param { Callback<Range> } callback - processes selectByRange command. The range of selection is provided for 1164 * this callback, and subscribers are expected to select corresponding text in callback according to 1165 * the range. 1166 * @throws { BusinessError } 401 - parameter error. Possible causes: 1167 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1168 * @syscap SystemCapability.MiscServices.InputMethodFramework 1169 * @since 10 1170 */ 1171 on(type: 'selectByRange', callback: Callback<Range>): void; 1172 1173 /** 1174 * Unregister the callback of selectedByRange. 1175 * 1176 * @param { 'selectByRange' } type - event type, fixed as 'selectByRange'. 1177 * @param { Callback<Range> } [callback] - the callback of 'selectByRange', 1178 * when subscriber unsubscribes all callback functions of event 'selectByRange', this parameter can be left blank. 1179 * @syscap SystemCapability.MiscServices.InputMethodFramework 1180 * @since 10 1181 */ 1182 off(type: 'selectByRange', callback?: Callback<Range>): void; 1183 1184 /** 1185 * Register a callback and when IME sends select event witch movement of cursor, 1186 * the callback will be invoked. 1187 * 1188 * @param { 'selectByMovement' } type - event type, fixed as 'selectByMovement'. 1189 * @param { Callback<Movement> } callback - processes selectByMovement command. The movement of cursor is provided 1190 * for this callback, and subscribers are expected to select corresponding text in callback according to 1191 * the movement. 1192 * @throws { BusinessError } 401 - parameter error. Possible causes: 1193 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1194 * @syscap SystemCapability.MiscServices.InputMethodFramework 1195 * @since 10 1196 */ 1197 on(type: 'selectByMovement', callback: Callback<Movement>): void; 1198 1199 /** 1200 * Unregister the callback of selectedByMovement. 1201 * 1202 * @param { 'selectByMovement' } type - event type, fixed as 'selectByMovement'. 1203 * @param { Callback<Movement> } [callback] - the callback of 'selectByMovement', 1204 * when subscriber unsubscribes all callback functions of event 'selectByMovement', this parameter can be left blank. 1205 * @syscap SystemCapability.MiscServices.InputMethodFramework 1206 * @since 10 1207 */ 1208 off(type: 'selectByMovement', callback?: Callback<Movement>): void; 1209 1210 /** 1211 * Register a callback and when IME sends insert text event, the callback will be invoked. 1212 * 1213 * @param { 'insertText' } type - event type, fixed as 'insertText'. 1214 * @param { function } callback - processes insertText command. The text of insert is provided for this callback. 1215 * Subscribers are expected to process the inserted text and update changes in editor by changeSelection and updateCursor as needed. 1216 * @throws { BusinessError } 401 - parameter error. Possible causes: 1217 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1218 * @throws { BusinessError } 12800009 - input method client detached. 1219 * @syscap SystemCapability.MiscServices.InputMethodFramework 1220 * @since 10 1221 */ 1222 on(type: 'insertText', callback: (text: string) => void): void; 1223 1224 /** 1225 * Unregister the callback of insertText. 1226 * 1227 * @param { 'insertText' } type - event type, fixed as 'insertText'. 1228 * @param { function } [callback] - the callback of 'insertText', 1229 * when subscriber unsubscribes all callback functions of event 'insertText', this parameter can be left blank. 1230 * @syscap SystemCapability.MiscServices.InputMethodFramework 1231 * @since 10 1232 */ 1233 off(type: 'insertText', callback?: (text: string) => void): void; 1234 1235 /** 1236 * Register a callback and when IME sends delete left event with length, 1237 * the callback will be invoked. 1238 * 1239 * @param { 'deleteLeft' } type - event type, fixed as 'deleteLeft'. 1240 * @param { function } callback - processes deleteLeft command. The length of 1241 * delete is provided for this callback. Subscribers are expected to delete specified length of text 1242 * to the left of the cursor and update changes in editor by changeSelection and updateCursor as needed. 1243 * @throws { BusinessError } 401 - parameter error. Possible causes: 1244 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1245 * @throws { BusinessError } 12800009 - input method client detached. 1246 * @syscap SystemCapability.MiscServices.InputMethodFramework 1247 * @since 10 1248 */ 1249 on(type: 'deleteLeft', callback: (length: number) => void): void; 1250 1251 /** 1252 * Unregister the callback of deleteLeft. 1253 * 1254 * @param { 'deleteLeft' } type - event type, fixed as 'deleteLeft'. 1255 * @param { function } [callback] - the callback of 'deleteLeft', 1256 * when subscriber unsubscribes all callback functions of event 'deleteLeft', this parameter can be left blank. 1257 * @syscap SystemCapability.MiscServices.InputMethodFramework 1258 * @since 10 1259 */ 1260 off(type: 'deleteLeft', callback?: (length: number) => void): void; 1261 1262 /** 1263 * Register a callback and when IME sends delete right event with length, 1264 * the callback will be invoked. 1265 * 1266 * @param { 'deleteRight' } type - event type, fixed as 'deleteRight'. 1267 * @param { function } callback - processes deleteRight command. The length of 1268 * delete is provided for this callback. Subscribers are expected to delete specified length of text 1269 * to the right of the cursor and update changes in editor by changeSelection and updateCursor as needed. 1270 * @throws { BusinessError } 401 - parameter error. Possible causes: 1271 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1272 * @throws { BusinessError } 12800009 - input method client detached. 1273 * @syscap SystemCapability.MiscServices.InputMethodFramework 1274 * @since 10 1275 */ 1276 on(type: 'deleteRight', callback: (length: number) => void): void; 1277 1278 /** 1279 * Unregister the callback of deleteRight. 1280 * 1281 * @param { 'deleteRight' } type - event type, fixed as 'deleteRight'. 1282 * @param { function } [callback] - the callback of 'deleteRight', 1283 * when subscriber unsubscribes all callback functions of event 'deleteRight', this parameter can be left blank. 1284 * @syscap SystemCapability.MiscServices.InputMethodFramework 1285 * @since 10 1286 */ 1287 off(type: 'deleteRight', callback?: (length: number) => void): void; 1288 1289 /** 1290 * Register a callback and when IME sends keyboard status, the callback will be invoked. 1291 * 1292 * @param { 'sendKeyboardStatus' } type - event type, fixed as 'sendKeyboardStatus'. 1293 * @param { function } callback - processes sendKeyboardStatus command. 1294 * The keyboardStatus is provided for this callback. 1295 * @throws { BusinessError } 401 - parameter error. Possible causes: 1296 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1297 * @throws { BusinessError } 12800009 - input method client detached. 1298 * @syscap SystemCapability.MiscServices.InputMethodFramework 1299 * @since 10 1300 */ 1301 on(type: 'sendKeyboardStatus', callback: (keyboardStatus: KeyboardStatus) => void): void; 1302 1303 /** 1304 * Unregister the callback of sendKeyboardStatus. 1305 * 1306 * @param { 'sendKeyboardStatus' } type - event type, fixed as 'sendKeyboardStatus'. 1307 * @param { function } [callback] - the callback of 'sendKeyboardStatus', 1308 * when subscriber unsubscribes all callback functions of event 'sendKeyboardStatus', this parameter can be left blank. 1309 * @syscap SystemCapability.MiscServices.InputMethodFramework 1310 * @since 10 1311 */ 1312 off(type: 'sendKeyboardStatus', callback?: (keyboardStatus: KeyboardStatus) => void): void; 1313 1314 /** 1315 * Register a callback and when IME sends functionKey, the callback will be invoked. 1316 * 1317 * @param { 'sendFunctionKey' } type - event type, fixed as 'sendFunctionKey'. 1318 * @param { function } callback - processes sendFunctionKey command. 1319 * The functionKey is provided for this callback.Subscribers are expected to complete the 1320 * corresponding task based on the value of functionKey. 1321 * @throws { BusinessError } 401 - parameter error. Possible causes: 1322 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1323 * @throws { BusinessError } 12800009 - input method client detached. 1324 * @syscap SystemCapability.MiscServices.InputMethodFramework 1325 * @since 10 1326 */ 1327 on(type: 'sendFunctionKey', callback: (functionKey: FunctionKey) => void): void; 1328 1329 /** 1330 * Unregister the callback of sendFunctionKey. 1331 * 1332 * @param { 'sendFunctionKey' } type - event type, fixed as 'sendFunctionKey'. 1333 * @param { function } [callback] - the callback of 'sendFunctionKey', 1334 * when subscriber unsubscribes all callback functions of event 'sendFunctionKey', this parameter can be left blank. 1335 * @syscap SystemCapability.MiscServices.InputMethodFramework 1336 * @since 10 1337 */ 1338 off(type: 'sendFunctionKey', callback?: (functionKey: FunctionKey) => void): void; 1339 1340 /** 1341 * Register a callback and when IME sends move cursor, the callback will be invoked. 1342 * 1343 * @param { 'moveCursor' } type - event type, fixed as 'moveCursor'. 1344 * @param { function } callback - processes moveCursor command. The direction of 1345 * cursor is provided for this callback. Subscribers are expected to move the cursor and update changes 1346 * in editor by changeSelection and updateCursor. 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 } 12800009 - input method client detached. 1350 * @syscap SystemCapability.MiscServices.InputMethodFramework 1351 * @since 10 1352 */ 1353 on(type: 'moveCursor', callback: (direction: Direction) => void): void; 1354 1355 /** 1356 * Unregister the callback of moveCursor. 1357 * 1358 * @param { 'moveCursor' } type - event type, fixed as 'moveCursor'. 1359 * @param { function } [callback] - the callback of 'moveCursor', 1360 * when subscriber unsubscribes all callback functions of event 'moveCursor', this parameter can be left blank. 1361 * @syscap SystemCapability.MiscServices.InputMethodFramework 1362 * @since 10 1363 */ 1364 off(type: 'moveCursor', callback?: (direction: Direction) => void): void; 1365 1366 /** 1367 * Register a callback and when IME sends extend action code, the callback will be invoked. 1368 * 1369 * @param { 'handleExtendAction' } type - event type, fixed as 'handleExtendAction'. 1370 * @param { function } callback - processes handleExtendAction command. The action code 1371 * is provided for this callback. 1372 * @throws { BusinessError } 401 - parameter error. Possible causes: 1373 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1374 * @throws { BusinessError } 12800009 - input method client detached. 1375 * @syscap SystemCapability.MiscServices.InputMethodFramework 1376 * @since 10 1377 */ 1378 on(type: 'handleExtendAction', callback: (action: ExtendAction) => void): void; 1379 1380 /** 1381 * Unregister the callback of handleExtendAction. 1382 * 1383 * @param { 'handleExtendAction' } type - event type, fixed as 'handleExtendAction'. 1384 * @param { function } [callback] - the callback of 'handleExtendAction', 1385 * when subscriber unsubscribes all callback functions of event 'handleExtendAction', this parameter can be left blank. 1386 * @syscap SystemCapability.MiscServices.InputMethodFramework 1387 * @since 10 1388 */ 1389 off(type: 'handleExtendAction', callback?: (action: ExtendAction) => void): void; 1390 1391 /** 1392 * Register a callback and when input method ability gets left text of cursor, the callback will be invoked. 1393 * 1394 * @param { 'getLeftTextOfCursor' } type - event type, fixed as 'getLeftTextOfCursor'. 1395 * @param { function } callback - processes getLeftTextOfCursor command. The callback 1396 * must be a synchronization method and will block the input method application. 1397 * @throws { BusinessError } 401 - parameter error. Possible causes: 1398 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1399 * @throws { BusinessError } 12800009 - input method client detached. 1400 * @syscap SystemCapability.MiscServices.InputMethodFramework 1401 * @since 10 1402 */ 1403 on(type: 'getLeftTextOfCursor', callback: (length: number) => string): void; 1404 1405 /** 1406 * Unregister the callback of getLeftTextOfCursor event. 1407 * 1408 * @param { 'getLeftTextOfCursor' } type - event type, fixed as 'getLeftTextOfCursor'. 1409 * @param { function } [callback] - the callback of 'getLeftTextOfCursor', 1410 * when subscriber unsubscribes all callback functions of event 'getLeftTextOfCursor', this parameter can be left blank. 1411 * @syscap SystemCapability.MiscServices.InputMethodFramework 1412 * @since 10 1413 */ 1414 off(type: 'getLeftTextOfCursor', callback?: (length: number) => string): void; 1415 1416 /** 1417 * Register a callback and when input method ability gets right text of cursor, the callback will be invoked. 1418 * 1419 * @param { 'getRightTextOfCursor' } type - event type, fixed as 'getRightTextOfCursor'. 1420 * @param { function } callback - processes getRightTextOfCursor command. The callback 1421 * must be a synchronization method and will block the input method application. 1422 * @throws { BusinessError } 401 - parameter error. Possible causes: 1423 * 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. 1424 * @throws { BusinessError } 12800009 - input method client detached. 1425 * @syscap SystemCapability.MiscServices.InputMethodFramework 1426 * @since 10 1427 */ 1428 on(type: 'getRightTextOfCursor', callback: (length: number) => string): void; 1429 1430 /** 1431 * Unregister the callback of getRightTextOfCursor event. 1432 * 1433 * @param { 'getRightTextOfCursor' } type - event type, fixed as 'getRightTextOfCursor'. 1434 * @param { function } [callback] - the callback of 'getRightTextOfCursor', 1435 * when subscriber unsubscribes all callback functions of event 'getRightTextOfCursor', this parameter can be left blank. 1436 * @syscap SystemCapability.MiscServices.InputMethodFramework 1437 * @since 10 1438 */ 1439 off(type: 'getRightTextOfCursor', callback?: (length: number) => string): void; 1440 1441 /** 1442 * Register a callback and when input method ability gets the text index at cursor, the callback will be invoked. 1443 * 1444 * @param { 'getTextIndexAtCursor' } type - event type, fixed as 'getTextIndexAtCursor'. 1445 * @param { function } callback - processes getTextIndexAtCursor command. The callback 1446 * must be a synchronization method, and should return the text index at the cursor. 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 } 12800009 - input method client detached. 1450 * @syscap SystemCapability.MiscServices.InputMethodFramework 1451 * @since 10 1452 */ 1453 on(type: 'getTextIndexAtCursor', callback: () => number): void; 1454 1455 /** 1456 * Unregister the callback of getTextIndexAtCursor. 1457 * 1458 * @param { 'getTextIndexAtCursor' } type - event type, fixed as 'getTextIndexAtCursor'. 1459 * @param { function } [callback] - the callback of 'getTextIndexAtCursor', 1460 * when subscriber unsubscribes all callback functions of event 'getTextIndexAtCursor', this parameter can be left blank. 1461 * @syscap SystemCapability.MiscServices.InputMethodFramework 1462 * @since 10 1463 */ 1464 off(type: 'getTextIndexAtCursor', callback?: () => number): void; 1465 1466 /** 1467 * <p>Subscribe 'setPreviewText' event.</p> 1468 * <p>To support the preview text feature, developers should subscribe to this event before calling attach.</p> 1469 * 1470 * @param { 'setPreviewText' } type - the type of subscribe event. 1471 * @param { SetPreviewTextCallback } callback - the callback of on('setPreviewText'). 1472 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1473 * 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed. 1474 * @syscap SystemCapability.MiscServices.InputMethodFramework 1475 * @since 17 1476 */ 1477 on(type: 'setPreviewText', callback: SetPreviewTextCallback): void; 1478 1479 /** 1480 * Unsubscribe 'setPreviewText' event. 1481 * 1482 * @param { 'setPreviewText' } type - the type of unsubscribe event. 1483 * @param { SetPreviewTextCallback } [callback] - optional, the callback of off('setPreviewText'). 1484 * @syscap SystemCapability.MiscServices.InputMethodFramework 1485 * @since 17 1486 */ 1487 off(type: 'setPreviewText', callback?: SetPreviewTextCallback): void; 1488 1489 /** 1490 * <p>Subscribe 'finishTextPreview' event.</p> 1491 * <p>To support the preview text feature, developers should subscribe to this event before calling attach.</p> 1492 * 1493 * @param { 'finishTextPreview' } type - the type of subscribe event. 1494 * @param { Callback<void> } callback - the callback of on('finishTextPreview'). 1495 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1496 * 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3.Parameter verification failed. 1497 * @syscap SystemCapability.MiscServices.InputMethodFramework 1498 * @since 17 1499 */ 1500 on(type: 'finishTextPreview', callback: Callback<void>): void; 1501 1502 /** 1503 * Unsubscribe 'finishTextPreview' event. 1504 * 1505 * @param { 'finishTextPreview' } type - the type of unsubscribe event. 1506 * @param { Callback<void> } [callback] - optional, the callback of off('finishTextPreview'). 1507 * @syscap SystemCapability.MiscServices.InputMethodFramework 1508 * @since 17 1509 */ 1510 off(type: 'finishTextPreview', callback?: Callback<void>): void; 1511 } 1512 1513 /** 1514 * input method property 1515 * 1516 * @interface InputMethodProperty 1517 * @syscap SystemCapability.MiscServices.InputMethodFramework 1518 * @since 8 1519 */ 1520 interface InputMethodProperty { 1521 /** 1522 * The name of input method 1523 * 1524 * @type { string } 1525 * @syscap SystemCapability.MiscServices.InputMethodFramework 1526 * @since 8 1527 * @deprecated since 9 1528 * @useinstead inputMethod.InputMethodProperty#name 1529 */ 1530 readonly packageName: string; 1531 1532 /** 1533 * The id of input method 1534 * 1535 * @type { string } 1536 * @syscap SystemCapability.MiscServices.InputMethodFramework 1537 * @since 8 1538 * @deprecated since 9 1539 * @useinstead inputMethod.InputMethodProperty#id 1540 */ 1541 readonly methodId: string; 1542 1543 /** 1544 * The name of input method 1545 * 1546 * @type { string } 1547 * @readonly 1548 * @syscap SystemCapability.MiscServices.InputMethodFramework 1549 * @since 9 1550 */ 1551 readonly name: string; 1552 1553 /** 1554 * The id of input method 1555 * 1556 * @type { string } 1557 * @readonly 1558 * @syscap SystemCapability.MiscServices.InputMethodFramework 1559 * @since 9 1560 */ 1561 readonly id: string; 1562 1563 /** 1564 * The label of input method 1565 * 1566 * @type { ?string } 1567 * @readonly 1568 * @syscap SystemCapability.MiscServices.InputMethodFramework 1569 * @since 9 1570 */ 1571 readonly label?: string; 1572 1573 /** 1574 * The label id of input method 1575 * 1576 * @type { ?number } 1577 * @readonly 1578 * @syscap SystemCapability.MiscServices.InputMethodFramework 1579 * @since 10 1580 */ 1581 readonly labelId?: number; 1582 1583 /** 1584 * The icon of input method 1585 * 1586 * @type { ?string } 1587 * @readonly 1588 * @syscap SystemCapability.MiscServices.InputMethodFramework 1589 * @since 9 1590 */ 1591 readonly icon?: string; 1592 1593 /** 1594 * The icon id of input method 1595 * 1596 * @type { ?number } 1597 * @readonly 1598 * @syscap SystemCapability.MiscServices.InputMethodFramework 1599 * @since 9 1600 */ 1601 readonly iconId?: number; 1602 1603 /** 1604 * The enabledState of input method 1605 * 1606 * @type { ?EnabledState } 1607 * @readonly 1608 * @syscap SystemCapability.MiscServices.InputMethodFramework 1609 * @since 20 1610 */ 1611 readonly enabledState?: EnabledState; 1612 1613 /** 1614 * The extra info of input method 1615 * 1616 * @type { object } 1617 * @syscap SystemCapability.MiscServices.InputMethodFramework 1618 * @since 9 1619 */ 1620 /** 1621 * The extra info of input method 1622 * 1623 * @type { ?object } 1624 * @syscap SystemCapability.MiscServices.InputMethodFramework 1625 * @since 10 1626 */ 1627 extra?: object; 1628 } 1629 1630 /** 1631 * Enumerates the moving direction of cursor 1632 * 1633 * @enum { number } 1634 * @syscap SystemCapability.MiscServices.InputMethodFramework 1635 * @since 10 1636 */ 1637 export enum Direction { 1638 /** 1639 * Cursor moves up 1640 * 1641 * @syscap SystemCapability.MiscServices.InputMethodFramework 1642 * @since 10 1643 */ 1644 CURSOR_UP = 1, 1645 1646 /** 1647 * Cursor moves down 1648 * 1649 * @syscap SystemCapability.MiscServices.InputMethodFramework 1650 * @since 10 1651 */ 1652 CURSOR_DOWN, 1653 1654 /** 1655 * Cursor moves left 1656 * 1657 * @syscap SystemCapability.MiscServices.InputMethodFramework 1658 * @since 10 1659 */ 1660 CURSOR_LEFT, 1661 1662 /** 1663 * Cursor moves right 1664 * 1665 * @syscap SystemCapability.MiscServices.InputMethodFramework 1666 * @since 10 1667 */ 1668 CURSOR_RIGHT 1669 } 1670 1671 /** 1672 * Range of selected text. 1673 * 1674 * @typedef Range 1675 * @syscap SystemCapability.MiscServices.InputMethodFramework 1676 * @since 10 1677 */ 1678 export interface Range { 1679 /** 1680 * Indicates the index of the first character of the selected text. 1681 * 1682 * @type { number } 1683 * @syscap SystemCapability.MiscServices.InputMethodFramework 1684 * @since 10 1685 */ 1686 start: number; 1687 1688 /** 1689 * Indicates the index of the last character of the selected text. 1690 * 1691 * @type { number } 1692 * @syscap SystemCapability.MiscServices.InputMethodFramework 1693 * @since 10 1694 */ 1695 end: number; 1696 } 1697 1698 /** 1699 * Movement of cursor. 1700 * 1701 * @typedef Movement 1702 * @syscap SystemCapability.MiscServices.InputMethodFramework 1703 * @since 10 1704 */ 1705 export interface Movement { 1706 /** 1707 * Indicates the direction of cursor movement 1708 * 1709 * @type { Direction } 1710 * @syscap SystemCapability.MiscServices.InputMethodFramework 1711 * @since 10 1712 */ 1713 direction: Direction; 1714 } 1715 1716 /** 1717 * Enumerates the text input type. 1718 * 1719 * @enum { number } 1720 * @syscap SystemCapability.MiscServices.InputMethodFramework 1721 * @since 10 1722 */ 1723 export enum TextInputType { 1724 /** 1725 * The text input type is NONE. 1726 * 1727 * @syscap SystemCapability.MiscServices.InputMethodFramework 1728 * @since 10 1729 */ 1730 NONE = -1, 1731 1732 /** 1733 * The text input type is TEXT. 1734 * 1735 * @syscap SystemCapability.MiscServices.InputMethodFramework 1736 * @since 10 1737 */ 1738 TEXT = 0, 1739 1740 /** 1741 * The text input type is MULTILINE. 1742 * 1743 * @syscap SystemCapability.MiscServices.InputMethodFramework 1744 * @since 10 1745 */ 1746 MULTILINE, 1747 1748 /** 1749 * The text input type is NUMBER. 1750 * 1751 * @syscap SystemCapability.MiscServices.InputMethodFramework 1752 * @since 10 1753 */ 1754 NUMBER, 1755 1756 /** 1757 * The text input type is PHONE. 1758 * 1759 * @syscap SystemCapability.MiscServices.InputMethodFramework 1760 * @since 10 1761 */ 1762 PHONE, 1763 1764 /** 1765 * The text input type is DATETIME. 1766 * 1767 * @syscap SystemCapability.MiscServices.InputMethodFramework 1768 * @since 10 1769 */ 1770 DATETIME, 1771 1772 /** 1773 * The text input type is EMAIL_ADDRESS. 1774 * 1775 * @syscap SystemCapability.MiscServices.InputMethodFramework 1776 * @since 10 1777 */ 1778 EMAIL_ADDRESS, 1779 1780 /** 1781 * The text input type is URL. 1782 * 1783 * @syscap SystemCapability.MiscServices.InputMethodFramework 1784 * @since 10 1785 */ 1786 URL, 1787 1788 /** 1789 * The text input type is VISIBLE_PASSWORD. 1790 * 1791 * @syscap SystemCapability.MiscServices.InputMethodFramework 1792 * @since 10 1793 */ 1794 VISIBLE_PASSWORD, 1795 1796 /** 1797 * The text input type is NUMBER_PASSWORD. 1798 * 1799 * @syscap SystemCapability.MiscServices.InputMethodFramework 1800 * @since 11 1801 */ 1802 NUMBER_PASSWORD, 1803 1804 /** 1805 * The text input type is SCREEN_LOCK_PASSWORD. 1806 * 1807 * @syscap SystemCapability.MiscServices.InputMethodFramework 1808 * @since 20 1809 */ 1810 SCREEN_LOCK_PASSWORD, 1811 1812 /** 1813 * The text input type is USER_NAME. 1814 * 1815 * @syscap SystemCapability.MiscServices.InputMethodFramework 1816 * @since 20 1817 */ 1818 USER_NAME, 1819 1820 /** 1821 * The text input type is NEW_PASSWORD. 1822 * 1823 * @syscap SystemCapability.MiscServices.InputMethodFramework 1824 * @since 20 1825 */ 1826 NEW_PASSWORD, 1827 1828 /** 1829 * The text input type is NUMBER_DECIMAL. 1830 * 1831 * @syscap SystemCapability.MiscServices.InputMethodFramework 1832 * @since 20 1833 */ 1834 NUMBER_DECIMAL, 1835 1836 /** 1837 * The text input type is ONE_TIME_CODE. 1838 * 1839 * @syscap SystemCapability.MiscServices.InputMethodFramework 1840 * @since 20 1841 */ 1842 ONE_TIME_CODE 1843 } 1844 1845 /** 1846 * Enumerates the enter key type. 1847 * 1848 * @enum { number } 1849 * @syscap SystemCapability.MiscServices.InputMethodFramework 1850 * @since 10 1851 */ 1852 export enum EnterKeyType { 1853 /** 1854 * The enter key type is UNSPECIFIED. 1855 * 1856 * @syscap SystemCapability.MiscServices.InputMethodFramework 1857 * @since 10 1858 */ 1859 UNSPECIFIED = 0, 1860 1861 /** 1862 * The enter key type is NONE. 1863 * 1864 * @syscap SystemCapability.MiscServices.InputMethodFramework 1865 * @since 10 1866 */ 1867 NONE, 1868 1869 /** 1870 * The enter key type is GO. 1871 * 1872 * @syscap SystemCapability.MiscServices.InputMethodFramework 1873 * @since 10 1874 */ 1875 GO, 1876 1877 /** 1878 * The enter key type is SEARCH. 1879 * 1880 * @syscap SystemCapability.MiscServices.InputMethodFramework 1881 * @since 10 1882 */ 1883 SEARCH, 1884 1885 /** 1886 * The enter key type is SEND. 1887 * 1888 * @syscap SystemCapability.MiscServices.InputMethodFramework 1889 * @since 10 1890 */ 1891 SEND, 1892 1893 /** 1894 * The enter key type is NEXT. 1895 * 1896 * @syscap SystemCapability.MiscServices.InputMethodFramework 1897 * @since 10 1898 */ 1899 NEXT, 1900 1901 /** 1902 * The enter key type is DONE. 1903 * 1904 * @syscap SystemCapability.MiscServices.InputMethodFramework 1905 * @since 10 1906 */ 1907 DONE, 1908 1909 /** 1910 * The enter key type is PREVIOUS. 1911 * 1912 * @syscap SystemCapability.MiscServices.InputMethodFramework 1913 * @since 10 1914 */ 1915 PREVIOUS, 1916 1917 /** 1918 * The enter key type is NEWLINE. 1919 * 1920 * @syscap SystemCapability.MiscServices.InputMethodFramework 1921 * @since 12 1922 */ 1923 NEWLINE 1924 } 1925 1926 /** 1927 * Enumerates the keyboard status. 1928 * 1929 * @enum { number } 1930 * @syscap SystemCapability.MiscServices.InputMethodFramework 1931 * @since 10 1932 */ 1933 export enum KeyboardStatus { 1934 /** 1935 * The keyboard status is none. 1936 * 1937 * @syscap SystemCapability.MiscServices.InputMethodFramework 1938 * @since 10 1939 */ 1940 NONE = 0, 1941 1942 /** 1943 * The keyboard status is hide. 1944 * 1945 * @syscap SystemCapability.MiscServices.InputMethodFramework 1946 * @since 10 1947 */ 1948 HIDE = 1, 1949 1950 /** 1951 * The keyboard status is show. 1952 * 1953 * @syscap SystemCapability.MiscServices.InputMethodFramework 1954 * @since 10 1955 */ 1956 SHOW = 2 1957 } 1958 1959 /** 1960 * Attribute of Input. 1961 * 1962 * @typedef InputAttribute 1963 * @syscap SystemCapability.MiscServices.InputMethodFramework 1964 * @since 10 1965 */ 1966 export interface InputAttribute { 1967 /** 1968 * Indicates the text input type of the input method. 1969 * 1970 * @type { TextInputType } 1971 * @syscap SystemCapability.MiscServices.InputMethodFramework 1972 * @since 10 1973 */ 1974 textInputType: TextInputType; 1975 1976 /** 1977 * Indicates the enter key type of the input method. 1978 * 1979 * @type { EnterKeyType } 1980 * @syscap SystemCapability.MiscServices.InputMethodFramework 1981 * @since 10 1982 */ 1983 enterKeyType: EnterKeyType; 1984 1985 /** 1986 * Placeholder text in the edit box. 1987 * 1988 * @type { ?string } 1989 * @syscap SystemCapability.MiscServices.InputMethodFramework 1990 * @since 20 1991 */ 1992 placeholder?: string; 1993 1994 /** 1995 * The name of the ability where the edit box is located. 1996 * 1997 * @type { ?string } 1998 * @syscap SystemCapability.MiscServices.InputMethodFramework 1999 * @since 20 2000 */ 2001 abilityName?: string; 2002 } 2003 2004 /** 2005 * FunctionKey of Input. 2006 * 2007 * @typedef FunctionKey 2008 * @syscap SystemCapability.MiscServices.InputMethodFramework 2009 * @since 10 2010 */ 2011 export interface FunctionKey { 2012 /** 2013 * Indicates the enter key type of the input method. 2014 * 2015 * @type { EnterKeyType } 2016 * @syscap SystemCapability.MiscServices.InputMethodFramework 2017 * @since 10 2018 */ 2019 enterKeyType: EnterKeyType; 2020 } 2021 2022 /** 2023 * Information of Cursor. 2024 * 2025 * @typedef CursorInfo 2026 * @syscap SystemCapability.MiscServices.InputMethodFramework 2027 * @since 10 2028 */ 2029 export interface CursorInfo { 2030 /** 2031 * Indicates the left point of the cursor info and must be absolute coordinate of the physical screen. 2032 * 2033 * @type { number } 2034 * @syscap SystemCapability.MiscServices.InputMethodFramework 2035 * @since 10 2036 */ 2037 left: number; 2038 2039 /** 2040 * Indicates the top point of the cursor info and must be absolute coordinate of the physical screen. 2041 * 2042 * @type { number } 2043 * @syscap SystemCapability.MiscServices.InputMethodFramework 2044 * @since 10 2045 */ 2046 top: number; 2047 2048 /** 2049 * Indicates the width point of the cursor info. 2050 * 2051 * @type { number } 2052 * @syscap SystemCapability.MiscServices.InputMethodFramework 2053 * @since 10 2054 */ 2055 width: number; 2056 2057 /** 2058 * Indicates the height point of the cursor info. 2059 * 2060 * @type { number } 2061 * @syscap SystemCapability.MiscServices.InputMethodFramework 2062 * @since 10 2063 */ 2064 height: number; 2065 } 2066 2067 /** 2068 * Config of editor. 2069 * 2070 * @typedef TextConfig 2071 * @syscap SystemCapability.MiscServices.InputMethodFramework 2072 * @since 10 2073 */ 2074 export interface TextConfig { 2075 /** 2076 * Attribute of Input. 2077 * 2078 * @type { InputAttribute } 2079 * @syscap SystemCapability.MiscServices.InputMethodFramework 2080 * @since 10 2081 */ 2082 inputAttribute: InputAttribute; 2083 2084 /** 2085 * Cursor information. 2086 * 2087 * @type { ?CursorInfo } 2088 * @syscap SystemCapability.MiscServices.InputMethodFramework 2089 * @since 10 2090 */ 2091 cursorInfo?: CursorInfo; 2092 2093 /** 2094 * Selection information. 2095 * 2096 * @type { ?Range } 2097 * @syscap SystemCapability.MiscServices.InputMethodFramework 2098 * @since 10 2099 */ 2100 selection?: Range; 2101 2102 /** 2103 * The window ID of the application currently bound to the input method. 2104 * 2105 * @type { ?number } 2106 * @syscap SystemCapability.MiscServices.InputMethodFramework 2107 * @since 10 2108 */ 2109 windowId?: number; 2110 2111 /** 2112 *Indicates that this is a new edit box. 2113 * 2114 * @type { ?boolean } 2115 * @syscap SystemCapability.MiscServices.InputMethodFramework 2116 * @since 20 2117 */ 2118 newEditBox?: boolean; 2119 2120 /** 2121 * Indicates the capitalize mode of the edit box. 2122 * 2123 * @type { ?CapitalizeMode } 2124 * @default CapitalizeMode.NONE 2125 * @syscap SystemCapability.MiscServices.InputMethodFramework 2126 * @since 20 2127 */ 2128 capitalizeMode?: CapitalizeMode; 2129 } 2130 2131 /** 2132 * Enumerates the extend action. 2133 * 2134 * @enum { number } 2135 * @syscap SystemCapability.MiscServices.InputMethodFramework 2136 * @since 10 2137 */ 2138 export enum ExtendAction { 2139 /** 2140 * Select all text. 2141 * 2142 * @syscap SystemCapability.MiscServices.InputMethodFramework 2143 * @since 10 2144 */ 2145 SELECT_ALL = 0, 2146 2147 /** 2148 * Cut selecting text. 2149 * 2150 * @syscap SystemCapability.MiscServices.InputMethodFramework 2151 * @since 10 2152 */ 2153 CUT = 3, 2154 2155 /** 2156 * Copy selecting text. 2157 * 2158 * @syscap SystemCapability.MiscServices.InputMethodFramework 2159 * @since 10 2160 */ 2161 COPY = 4, 2162 2163 /** 2164 * Paste from paste board. 2165 * 2166 * @syscap SystemCapability.MiscServices.InputMethodFramework 2167 * @since 10 2168 */ 2169 PASTE = 5 2170 } 2171 2172 /** 2173 * Information of input window. 2174 * 2175 * @typedef InputWindowInfo 2176 * @syscap SystemCapability.MiscServices.InputMethodFramework 2177 * @since 10 2178 */ 2179 export interface InputWindowInfo { 2180 /** 2181 * Indicates name of the input window. 2182 * 2183 * @type { string } 2184 * @syscap SystemCapability.MiscServices.InputMethodFramework 2185 * @since 10 2186 */ 2187 name: string; 2188 2189 /** 2190 * Indicates the abscissa of the upper-left vertex of input window. 2191 * 2192 * @type { number } 2193 * @syscap SystemCapability.MiscServices.InputMethodFramework 2194 * @since 10 2195 */ 2196 left: number; 2197 2198 /** 2199 * Indicates the ordinate of the upper-left vertex of input window. 2200 * 2201 * @type { number } 2202 * @syscap SystemCapability.MiscServices.InputMethodFramework 2203 * @since 10 2204 */ 2205 top: number; 2206 2207 /** 2208 * Indicates the width of the input window. 2209 * 2210 * @type { number } 2211 * @syscap SystemCapability.MiscServices.InputMethodFramework 2212 * @since 10 2213 */ 2214 width: number; 2215 2216 /** 2217 * Indicates the height of the input window. 2218 * 2219 * @type { number } 2220 * @syscap SystemCapability.MiscServices.InputMethodFramework 2221 * @since 10 2222 */ 2223 height: number; 2224 } 2225 2226 /** 2227 * <p>Custom message handler.</p> 2228 * <p>Implement this interface to respond to custem messages.</p> 2229 * 2230 * @interface MessageHandler 2231 * @syscap SystemCapability.MiscServices.InputMethodFramework 2232 * @since 15 2233 */ 2234 interface MessageHandler { 2235 /** 2236 * This method is called when a custom message is received. 2237 * 2238 * @param { string } msgId - the identifier of the message. 2239 * @param { ?ArrayBuffer } [msgParam] - the parameter of the custom message. 2240 * @syscap SystemCapability.MiscServices.InputMethodFramework 2241 * @since 15 2242 */ 2243 onMessage(msgId: string, msgParam?: ArrayBuffer): void; 2244 2245 /** 2246 * This method is called when a new message handler is set. 2247 * 2248 * @syscap SystemCapability.MiscServices.InputMethodFramework 2249 * @since 15 2250 */ 2251 onTerminated(): void; 2252 } 2253 2254 /** 2255 * Enumerates the enabled state. 2256 * 2257 * @enum { number } 2258 * @syscap SystemCapability.MiscServices.InputMethodFramework 2259 * @since 15 2260 */ 2261 export enum EnabledState { 2262 /** 2263 * Disabled state. 2264 * 2265 * @syscap SystemCapability.MiscServices.InputMethodFramework 2266 * @since 15 2267 */ 2268 DISABLED = 0, 2269 2270 /** 2271 * Enabled state with basic mode. 2272 * 2273 * @syscap SystemCapability.MiscServices.InputMethodFramework 2274 * @since 15 2275 */ 2276 BASIC_MODE, 2277 2278 /** 2279 * Enabled state with full experience mode. 2280 * 2281 * @syscap SystemCapability.MiscServices.InputMethodFramework 2282 * @since 15 2283 */ 2284 FULL_EXPERIENCE_MODE 2285 } 2286 2287 /** 2288 * requestKeyboardReason of input click 2289 * 2290 * @enum { number } 2291 * @syscap SystemCapability.MiscServices.InputMethodFramework 2292 * @since 15 2293 */ 2294 export enum RequestKeyboardReason { 2295 /** 2296 * The request keyboard reason is NONE. 2297 * @syscap SystemCapability.MiscServices.InputMethodFramework 2298 * @since 15 2299 */ 2300 NONE = 0, 2301 /** 2302 * The request keyboard reason is MOUSE. 2303 * @syscap SystemCapability.MiscServices.InputMethodFramework 2304 * @since 15 2305 */ 2306 MOUSE = 1, 2307 /** 2308 * The request keyboard reason is TOUCH. 2309 * @syscap SystemCapability.MiscServices.InputMethodFramework 2310 * @since 15 2311 */ 2312 TOUCH = 2, 2313 /** 2314 * The request keyboard reason is OTHER. 2315 * @syscap SystemCapability.MiscServices.InputMethodFramework 2316 * @since 15 2317 */ 2318 OTHER = 20 2319 } 2320 2321 /** 2322 * The callback of 'setPreviewText' event. 2323 * 2324 * @typedef { function } SetPreviewTextCallback. 2325 * @param { text } string - text to be previewed. 2326 * @param { range } Range - the range of the text to be replaced by the preview text. 2327 * @syscap SystemCapability.MiscServices.InputMethodFramework 2328 * @since 17 2329 */ 2330 export type SetPreviewTextCallback = (text: string, range: Range) => void; 2331 2332 /** 2333 * Enumerates the capitalization mode. 2334 * 2335 * @enum { number } 2336 * @syscap SystemCapability.MiscServices.InputMethodFramework 2337 * @since 20 2338 */ 2339 export enum CapitalizeMode { 2340 /** 2341 * Capitalize nothing. 2342 * 2343 * @syscap SystemCapability.MiscServices.InputMethodFramework 2344 * @since 20 2345 */ 2346 NONE = 0, 2347 2348 /** 2349 * Capitalize the first letter of each sentence. 2350 * 2351 * @syscap SystemCapability.MiscServices.InputMethodFramework 2352 * @since 20 2353 */ 2354 SENTENCES, 2355 2356 /** 2357 * Capitalize the first letter of each word. 2358 * 2359 * @syscap SystemCapability.MiscServices.InputMethodFramework 2360 * @since 20 2361 */ 2362 WORDS, 2363 2364 /** 2365 * Capitalize each letter. 2366 * 2367 * @syscap SystemCapability.MiscServices.InputMethodFramework 2368 * @since 20 2369 */ 2370 CHARACTERS 2371 } 2372} 2373 2374export default inputMethod;