diff --git a/api/@ohos.inputMethodSubtype.d.ts b/api/@ohos.inputMethodSubtype.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8927023d5784db3d4a97e15d86fe9a5dc4cc67ec --- /dev/null +++ b/api/@ohos.inputMethodSubtype.d.ts @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Input method subtype + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + export default interface InputMethodSubtype { + /** + * The label of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly label?: string; + + /** + * The name of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly name: string; + + /** + * The id of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly id: string; + + /** + * The mode of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly mode?: 'upper'|'lower'; + + /** + * The locale of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly locale: string; + + /** + * The language of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly language: string; + + /** + * The icon of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly icon?: string; + + /** + * The icon id of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly iconId?: number; + + /** + * The extra info of input method subtype. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + extra: object; +} \ No newline at end of file diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index a5d217b36d7813e069b75a38aa037c79a1201249..b551539641e0cf31f9e9d55d2575d4b930b6521b 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -14,36 +14,155 @@ */ import {AsyncCallback} from './basic'; +import InputMethodSubtype from './@ohos.inputMethodSubtype'; /** - * inputmethod + * Input method * + * @since 6 * @syscap SystemCapability.MiscServices.InputMethodFramework */ declare namespace inputMethod { /** - * keyboard max number + * Errorcode 201. The permissions check fails. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_PERMISSION: number; + + /** + * Errorcode 401. The parameters check fails. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_PARAMCHECK: number; + + /** + * Errorcode 801. Call unsupported api. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_UNSUPPORTED: number; + + /** + * Errorcode 12800001. Package manager error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_PACKAGEMANAGER: number; + + /** + * Errorcode 12800002. Input method engine error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_IMENGINE: number; + + /** + * Errorcode 12800003. Input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_IMCLIENT: number; + + /** + * Errorcode 12800004. Key event processing error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_KEYEVENT: number; + + /** + * Errorcode 12800005. Configuration persisting error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_CONFPERSIST: number; + + /** + * Errorcode 12800006. Input method controller error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_CONTROLLER: number; + + /** + * Errorcode 12800007. Input method settings extension error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_SETTINGS: number; + + /** + * Errorcode 12800008. Input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_IMMS: number; + + /** + * Errorcode 12899999. Others error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @since 9 + */ + const EXCEPTION_OTHERS: number; + + /** + * Keyboard max number * @since 8 */ const MAX_TYPE_NUM: number /** - * input method setting + * Input method setting * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethod.getController */ function getInputMethodSetting(): InputMethodSetting; /** - * input method controller + * Input method controller * @since 6 + * @deprecated since 9 + * @useinstead ohos.inputmethod.getController */ function getInputMethodController(): InputMethodController; + /** + * Input method setting + * @since 9 + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800007 - settings extension error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function getSetting(): InputMethodSetting; + + /** + * Input method controller + * @since 9 + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800006 - input method controller error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function getController(): InputMethodController; + /** * Switch input method * @since 9 * @param target Indicates the input method which will replace the current one - * @return - + * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800007 - settings extension error. + * @throws {BusinessError} 12800005 - configuration persisting error. * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ @@ -53,60 +172,268 @@ declare namespace inputMethod { * Switch input method * @since 9 * @param target Indicates the input method which will replace the current one - * @return - + * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800007 - settings extension error. + * @throws {BusinessError} 12800005 - configuration persisting error. * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ function switchInputMethod(target: InputMethodProperty): Promise; - + /** * Get current input method * @since 9 * @return The InputMethodProperty object of the current input method + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800007 - settings extension error. * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ function getCurrentInputMethod(): InputMethodProperty; + /** + * Switch current input method subtype + * @since 9 + * @param target Indicates the input method subtype which will replace the current one + * @return success or fail + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800005 - configuration persisting error. + * @throws {BusinessError} 12800007 - settings extension error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback): void; + + /** + * Switch current input method subtype + * @since 9 + * @param target Indicates the input method subtype which will replace the current one + * @return success or fail + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800005 - configuration persisting error. + * @throws {BusinessError} 12800007 - settings extension error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise; + + /** + * Get the current input method subtype + * @since 9 + * @return The InputMethodSubtype object of the current input method + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800007 - settings extension error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function getCurrentInputMethodSubtype(): InputMethodSubtype; + + /** + * Switch input method and subtype + * @since 9 + * @param inputMethodProperty Indicates the target input method + * @param inputMethodSubtype Indicates the target input method subtype + * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800005 - configuration persisting error. + * @throws {BusinessError} 12800007 - settings extension error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype, callback: AsyncCallback): void; + + /** + * Switch input method and subtype + * @since 9 + * @param inputMethodProperty Indicates the target input method + * @param inputMethodSubtype Indicates the target input method subtype + * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800005 - configuration persisting error. + * @throws {BusinessError} 12800007 - settings extension error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype): Promise; + /** * @since 8 */ interface InputMethodSetting { + /** + * Subscribe input method or subtype change + * @since 9 + * @param type Indicates the event type + * @return :- + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void; + + /** + * Unsubscribe input method or subtype change + * @since 9 + * @param type Indicates the event type + * @return :- + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype) => void): void; + + /** + * List subtype of the specified input method + * @since 9 + * @param inputMethodProperty Indicates the specified input method + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800001 - package manager error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback>): void; + + /** + * List subtype of the specified input method + * @since 9 + * @param inputMethodProperty Indicates the specified input method + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800001 - package manager error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise>; + + /** + * List subtype of current input method + * @since 9 + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800001 - package manager error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + listCurrentInputMethodSubtype(callback: AsyncCallback>): void; + + /** + * List subtype of current input method + * @since 9 + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800001 - package manager error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + listCurrentInputMethodSubtype(): Promise>; + /** * List input methods * @since 9 * @param enable : - * if true, collect enabled input methods. - * if false, collect disabled input methods. - * @return - + * If true, collect enabled input methods. + * If false, collect disabled input methods. + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800001 - package manager error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ - listInputMethod(enable: boolean, callback: AsyncCallback>): void; + getInputMethods(enable: boolean, callback: AsyncCallback>): void; /** * List input methods * @since 9 * @param enable : - * if true, collect enabled input methods. - * if false, collect disabled input methods. - * @return - + * If true, collect enabled input methods. + * If false, collect disabled input methods. + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800001 - package manager error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ - listInputMethod(enable: boolean): Promise>; + getInputMethods(enable: boolean): Promise>; /** * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethod.InputMethodSetting.getInputMethods */ listInputMethod(callback: AsyncCallback>): void; /** * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethod.InputMethodSetting.getInputMethods */ listInputMethod(): Promise>; + /** + * Show input method setting extension dialog + * @since 9 + * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800001 - package manager error. + * @throws {BusinessError} 12800007 - settings extension error. + * @throws {BusinessError} 12800005 - configuration persisting error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + showOptionalInputMethods(callback: AsyncCallback): void; + + /** + * Show input method setting extension dialog + * @since 9 + * @return - + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800001 - package manager error. + * @throws {BusinessError} 12800005 - configuration persisting error. + * @throws {BusinessError} 12800007 - settings extension error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + showOptionalInputMethods(): Promise; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethod.InputMethodSetting.showOptionalInputMethods + */ displayOptionalInputMethod(callback: AsyncCallback): void; + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethod.InputMethodSetting.showOptionalInputMethods + */ displayOptionalInputMethod(): Promise; } @@ -114,15 +441,59 @@ declare namespace inputMethod { * @since 6 */ interface InputMethodController { + /** + * Stop input + * @since 9 + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + stopInputSession(callback: AsyncCallback): void; + + /** + * Stop input + * @since 9 + * @return :- + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + stopInputSession(): Promise; + + /** + * Stop input + * @since 6 + * @deprecated since 9 + * @useinstead ohos.inputmethod.InputMethodController.stopInputSession + * @return :- + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ stopInput(callback: AsyncCallback): void; + /** + * Stop input + * @since 6 + * @deprecated since 9 + * @useinstead ohos.inputmethod.InputMethodController.stopInputSession + * @return :- + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ stopInput(): Promise; /** * Show soft keyboard * @since 9 - * @param callback * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ showSoftKeyboard(callback: AsyncCallback): void; @@ -131,36 +502,107 @@ declare namespace inputMethod { * Show soft keyboard * @since 9 * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ showSoftKeyboard():Promise; - + /** * Hide soft keyboard * @since 9 - * @param callback * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ hideSoftKeyboard(callback: AsyncCallback): void; - + /** * Hide soft keyboard * @since 9 * @return :- + * @permission ohos.permission.CONNECT_IME_ABILITY + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ hideSoftKeyboard():Promise; } /** - * input method info + * input method property * @since 8 */ interface InputMethodProperty { + /** + * The name of input method + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethod.InputMethodProperty.name + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ readonly packageName: string; + + /** + * The id of input method + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethod.InputMethodProperty.id + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ readonly methodId: string; + + /** + * The name of input method + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly name?: string; + + /** + * The id of input method + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly id?: string; + + /** + * The label of input method + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly label?: string; + + /** + * The icon of input method + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly icon?: string; + + /** + * The icon id of input method + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + readonly iconId?: number; + + /** + * The extra info of input method + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + extra?: object; } } -export default inputMethod; +export default inputMethod; \ No newline at end of file diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts index d9e1407055ce6900b2e081ceca825ba42d916f8f..9046751db98fad6e1302c64e3a4c694d98a15538 100644 --- a/api/@ohos.inputmethodengine.d.ts +++ b/api/@ohos.inputmethodengine.d.ts @@ -14,43 +14,169 @@ */ import {AsyncCallback} from './basic'; +import InputMethodSubtype from './@ohos.inputMethodSubtype'; /** - * inputmethodengine + * Input method engine * * @since 8 * @syscap SystemCapability.MiscServices.InputMethodFramework */ declare namespace inputMethodEngine { + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const ENTER_KEY_TYPE_UNSPECIFIED: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const ENTER_KEY_TYPE_GO: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const ENTER_KEY_TYPE_SEARCH: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const ENTER_KEY_TYPE_SEND: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const ENTER_KEY_TYPE_NEXT: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const ENTER_KEY_TYPE_DONE: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const ENTER_KEY_TYPE_PREVIOUS: number; + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const PATTERN_NULL: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const PATTERN_TEXT: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const PATTERN_NUMBER: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const PATTERN_PHONE: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const PATTERN_DATETIME: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const PATTERN_EMAIL: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const PATTERN_URI: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const PATTERN_PASSWORD: number; + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const FLAG_SELECTING: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const FLAG_SINGLE_LINE: number; + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const DISPLAY_MODE_PART: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const DISPLAY_MODE_FULL: number; + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const OPTION_ASCII: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const OPTION_NONE: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const OPTION_AUTO_CAP_CHARACTERS: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const OPTION_AUTO_CAP_SENTENCES: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const OPTION_AUTO_WORDS: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const OPTION_MULTI_LINE: number; + + /** + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ const OPTION_NO_FULLSCREEN: number; /** @@ -82,33 +208,154 @@ declare namespace inputMethodEngine { const CURSOR_RIGHT: number; /** - * The window styles for inputmethod ability. + * The window styles for input method ability. * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework */ const WINDOW_TYPE_INPUT_METHOD_FLOAT: number; + /** + * @since 9 + * @return InputMethodAbility object of the current input method + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 801 - call unsupported api. + * @throws {BusinessError} 12800002 - input method engine error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + function getInputMethodAbility(): InputMethodAbility; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.getInputMethodAbility + */ function getInputMethodEngine(): InputMethodEngine; + /** + * @since 9 + * @return KeyboardDelegate object of the current input method + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + function getKeyboardDelegate(): KeyboardDelegate; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.getKeyboardDelegate + */ function createKeyboardDelegate(): KeyboardDelegate; + /** + * @since 8 + */ interface KeyboardController { + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + hide(callback: AsyncCallback): void; + + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800008 - input method manager service error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + hide(): Promise; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.KeyboardController.hide + */ hideKeyboard(callback: AsyncCallback): void; + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.KeyboardController.hide + */ hideKeyboard(): Promise; } + /** + * @since 8 + */ interface InputMethodEngine { + /** + * Subscribe 'inputStart' + * @since 8 + * @param type inputStart + * @param callback give keyboard controller and text input client + * @return :- + */ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; + + /** + * Unsubscribe 'inputStart' + * @since 8 + * @param type inputStart + * @param callback optional, give keyboard controller and text input client + * @return :- + */ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; + /** + * Subscribe 'keyboardShow'|'keyboardHide' + * @since 8 + * @param type keyboardShow|keyboardHide + * @return :- + */ + on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void; + + /** + * Unsubscribe 'keyboardShow'|'keyboardHide' + * @since 8 + * @param type keyboardShow|keyboardHide + * @return :- + */ + off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void; + } + + /** + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + interface InputMethodAbility { + /** + * Subscribe 'inputStart' + * @since 9 + * @param type inputStart + * @param callback give keyboard controller and text input client + * @return :- + */ + on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: InputClient) => void): void; + + /** + * Unsubscribe 'inputStart' + * @since 9 + * @param type inputStart + * @param callback optional, give keyboard controller and text input client + * @return :- + */ + off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClient: InputClient) => void): void; + /** * Subscribe 'inputStop'. * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @param type inputStop - * @param callback - * @return - + * @return :- */ on(type: 'inputStop', callback: () => void): void; @@ -117,8 +364,7 @@ declare namespace inputMethodEngine { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @param type inputStop - * @param callback - * @return - + * @return :- */ off(type: 'inputStop', callback: () => void): void; @@ -127,8 +373,7 @@ declare namespace inputMethodEngine { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @param type setCallingWindow - * @param callback - * @return - + * @return :- */ on(type: 'setCallingWindow', callback: (wid:number) => void): void; @@ -137,41 +382,277 @@ declare namespace inputMethodEngine { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @param type setCallingWindow - * @param callback - * @return - + * @return :- */ off(type: 'setCallingWindow', callback: (wid:number) => void): void; + + /** + * Subscribe 'keyboardShow'|'keyboardHide' + * @since 9 + * @param type keyboardShow|keyboardHide + * @return :- + */ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void; + + /** + * Unsubscribe 'keyboardShow'|'keyboardHide' + * @since 9 + * @param type keyboardShow|keyboardHide + * @return :- + */ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void; + + /** + * Subscribe 'setSubtype' + * @since 9 + * @return :- + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => void): void; + + /** + * Unsubscribe 'setSubtype' + * @since 9 + * @return :- + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + off(ype: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void; } + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient + */ interface TextInputClient { + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.sendKeyFunction + */ + sendKeyFunction(action: number, callback: AsyncCallback): void; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.sendKeyFunction + */ + sendKeyFunction(action: number): Promise; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.deleteForward + */ + deleteForward(length: number, callback: AsyncCallback): void; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.deleteForward + */ + deleteForward(length: number): Promise; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.deleteBackward + */ + deleteBackward(length: number, callback: AsyncCallback): void; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.deleteBackward + */ + deleteBackward(length: number): Promise; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.insertText + */ + insertText(text: string, callback: AsyncCallback): void; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.insertText + */ + insertText(text: string): Promise; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.getForward + */ + getForward(length: number, callback: AsyncCallback): void; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.getForward + */ + getForward(length: number): Promise; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.getBackward + */ + getBackward(length: number, callback: AsyncCallback): void; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.getBackward + */ + getBackward(length: number): Promise; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.getEditorAttribute + */ + getEditorAttribute(callback: AsyncCallback): void; + + /** + * @since 8 + * @deprecated since 9 + * @useinstead ohos.inputmethodengine.InputClient.getEditorAttribute + */ + getEditorAttribute(): Promise; + } + + /** + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + interface InputClient { + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ sendKeyFunction(action: number, callback: AsyncCallback): void; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ sendKeyFunction(action: number): Promise; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ deleteForward(length: number, callback: AsyncCallback): void; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ deleteForward(length: number): Promise; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ deleteBackward(length: number, callback: AsyncCallback): void; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ deleteBackward(length: number): Promise; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ insertText(text: string, callback: AsyncCallback): void; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ insertText(text: string): Promise; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ getForward(length: number, callback: AsyncCallback): void; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ getForward(length: number): Promise; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ getBackward(length: number, callback: AsyncCallback): void; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ getBackward(length: number): Promise; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ getEditorAttribute(callback: AsyncCallback): void; + /** + * @since 9 + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ getEditorAttribute(): Promise; /** @@ -180,8 +661,10 @@ declare namespace inputMethodEngine { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @param direction Indicates the distance of cursor to be moved. - * @param callback * @return - + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. * @StageModelOnly */ moveCursor(direction: number, callback: AsyncCallback): void; @@ -193,38 +676,114 @@ declare namespace inputMethodEngine { * @syscap SystemCapability.MiscServices.InputMethodFramework * @param direction Indicates the distance of cursor to be moved. * @return - + * @throws {BusinessError} 201 - permissions check fails. + * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800003 - input method client error. * @StageModelOnly */ moveCursor(direction: number): Promise; } + /** + * @since 8 + */ interface KeyboardDelegate { + /** + * Subscribe key up or down event + * + * @since 8 + */ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void; + /** + * Unsubscribe key up or down event + * + * @since 8 + */ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void; + /** + * Subscribe cursor context change + * + * @since 8 + */ on(type: 'cursorContextChange', callback: (x: number, y: number, height: number) => void): void; + /** + * Unsubscribe cursor context change + * + * @since 8 + */ off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void; + /** + * Subscribe selection change + * + * @since 8 + */ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; + /** + * Unsubscribe selection change + * + * @since 8 + */ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; + /** + * Subscribe text change + * + * @since 8 + */ on(type: 'textChange', callback: (text: string) => void): void; + /** + * Unsubscribe text change + * + * @since 8 + */ off(type: 'textChange', callback?: (text: string) => void): void; } + /** + * @since 8 + */ interface EditorAttribute { + /** + * Editor's pattern + * + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ readonly inputPattern: number; + + /** + * Editor's key type + * + * @since 8 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ readonly enterKeyType: number; } + /** + * @since 8 + */ interface KeyEvent { + /** + * Key code + * + * @since 8 + */ readonly keyCode: number; + + /** + * Key action + * + * @since 8 + */ readonly keyAction: number; } } -export default inputMethodEngine; +export default inputMethodEngine; \ No newline at end of file diff --git a/api/@ohos.inputmethodextensionability.d.ts b/api/@ohos.inputmethodextensionability.d.ts index 16c5e3d423f69005ba1bfaedef944a49e9048059..9736dd016caeeb13a3e2bbf9d5ec8825ad8cf429 100644 --- a/api/@ohos.inputmethodextensionability.d.ts +++ b/api/@ohos.inputmethodextensionability.d.ts @@ -13,8 +13,9 @@ * limitations under the License. */ +import rpc from "./@ohos.rpc"; import Want from './@ohos.application.Want'; - +import ExtensionAbility from './@ohos.application.ExtensionAbility'; import InputMethodExtensionContext from "./@ohos.inputmethodextensioncontext"; /** @@ -24,10 +25,9 @@ import InputMethodExtensionContext from "./@ohos.inputmethodextensioncontext"; * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly */ -export default class InputMethodExtensionAbility { +export default class InputMethodExtensionAbility extends ExtensionAbility { /** * Indicates input method extension ability context. - * * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @StageModelOnly @@ -41,6 +41,7 @@ export default class InputMethodExtensionAbility { * @syscap SystemCapability.MiscServices.InputMethodFramework * @param want Indicates the want of created service extension. * @return - + * @throws {BusinessError} 401 - parameter error. * @StageModelOnly */ onCreate(want: Want): void; @@ -51,8 +52,60 @@ export default class InputMethodExtensionAbility { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @return - + * @throws {BusinessError} 401 - parameter error. * @StageModelOnly */ onDestroy(): void; + /** + * Called back when a input method extension is started. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the want of service extension to start. + * @param startId Indicates the number of times the service extension has been started. The {@code startId} is + * incremented by 1 every time the service extension is started. For example, if the service extension + * has been started for six times. + * @return - + * @throws {BusinessError} 401 - parameter error. + * @StageModelOnly + */ + onRequest(want: Want, startId: number): void; + + /** + * Called back when a input method extension is first connected to an ability. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates connection information about the Service ability. + * @return Returns the proxy of the Service ability. + * @throws {BusinessError} 401 - parameter error. + * @StageModelOnly + */ + onConnect(want: Want): rpc.RemoteObject; + + /** + * Called back when all abilities connected to a input method extension are disconnected. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates disconnection information about the service extension. + * @return - + * @throws {BusinessError} 401 - parameter error. + * @StageModelOnly + */ + onDisconnect(want: Want): void; + + /** + * Called when a new client attempts to connect to a input method extension after all previous client connections to it + * are disconnected. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the want of the service extension being connected. + * @return - + * @throws {BusinessError} 401 - parameter error. + * @StageModelOnly + */ + onReconnect(want: Want): void; } \ No newline at end of file diff --git a/api/@ohos.inputmethodextensioncontext.d.ts b/api/@ohos.inputmethodextensioncontext.d.ts index 59287c655f31ec7f22d4b7a086f3e7cf745dbe25..c09bd7e0a3264171c298d1168d60a9e2d161c9d8 100644 --- a/api/@ohos.inputmethodextensioncontext.d.ts +++ b/api/@ohos.inputmethodextensioncontext.d.ts @@ -30,15 +30,29 @@ export default class InputMethodExtensionContext extends ExtensionContext { * Input method extension uses this method to start a specific ability. * * @since 9 + * @deprecated since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @param want Indicates the ability to start. * @param options Indicates the start options. * @return - * @StageModelOnly */ - startAbility(want: Want, callback: AsyncCallback): void; - startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; - startAbility(want: Want, options?: StartOptions): Promise; + startAbility(want: Want, callback: AsyncCallback): void; + startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + startAbility(want: Want, options?: StartOptions): Promise; + + /** + * Destroy the input method extension. + * + * @since 9 + * @deprecated since 9 + * @useinstead ohos.inputmethodextensioncontext.InputMethodExtensionContext.destroy + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @return - + * @StageModelOnly + */ + terminateSelf(callback: AsyncCallback): void; + terminateSelf(): Promise; /** * Destroy the input method extension. @@ -46,8 +60,19 @@ export default class InputMethodExtensionContext extends ExtensionContext { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @return - + * @throws {BusinessError} 401 - parameter error. * @StageModelOnly */ - terminateSelf(callback: AsyncCallback): void; - terminateSelf(): Promise; + destroy(callback: AsyncCallback): void; + + /** + * Destroy the input method extension. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @return - + * @throws {BusinessError} 401 - parameter error. + * @StageModelOnly + */ + destroy(): Promise; } \ No newline at end of file