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