diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index fb1d97ce7d50fad4645d10c162eb39d3cf6da050..7d478a1a603bdcebb2a6321b886d2d3e0e58535b 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -39,10 +39,41 @@ declare namespace inputMethod { */ function getInputMethodController(): InputMethodController; + /** + * Switch input method + * @since 9 + * @param target Indicates the input method which will replace the current one + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): void; + function switchInputMethod(target: InputMethodProperty): Promise; + + /** + * Get current input method + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + function getCurrentInputMethod(): InputMethodProperty; + /** * @since 8 */ interface InputMethodSetting { + /** + * List input methods + * @since 9 + * @param enable A three-state flag: + * if true, collect enabled input methods. + * if false, collect disabled input methods. + * if not given, collect all input methods. + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + listInputMethod(callback: AsyncCallback>, enable?: boolean): void; + listInputMethod(enable?: boolean): Promise>; + listInputMethod(callback: AsyncCallback>): void; listInputMethod(): Promise>; diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts index 332c396c47aef608d08cf72af2d690f25c9a0d08..52ed3325dc2fb7045bd725456c303e6c1f8ff211 100644 --- a/api/@ohos.inputmethodengine.d.ts +++ b/api/@ohos.inputmethodengine.d.ts @@ -14,6 +14,11 @@ */ import {AsyncCallback} from './basic'; +import Want from './@ohos.application.Want'; +import StartOptions from "./@ohos.application.StartOptions"; +import { ConnectOptions } from "./ability/connectOptions"; +import ExtensionContext from './application/ExtensionContext'; +import { ExtensionAbilityInfo } from "./bundle/extensionAbilityInfo"; /** * inputmethodengine @@ -53,6 +58,13 @@ declare namespace inputMethodEngine { const OPTION_MULTI_LINE: number; const OPTION_NO_FULLSCREEN: number; + /** + * window style for inputmethod ability. + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + const WINDOW_TYPE_INPUT_METHOD_FLOAT: number; + function getInputMethodEngine(): InputMethodEngine; function createKeyboardDelegate(): KeyboardDelegate; @@ -101,6 +113,18 @@ declare namespace inputMethodEngine { getEditorAttribute(callback: AsyncCallback): void; getEditorAttribute(): Promise; + + /** + * Move curosr from input method. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param direction Indicates the distance of cursor to be moved. + * @return - + * @StageModelOnly + */ + moveCursor(direction: number, callback: AsyncCallback): void; + moveCursor(direction: number): Promise; } interface KeyboardDelegate { @@ -130,6 +154,152 @@ declare namespace inputMethodEngine { readonly keyCode: number; readonly keyAction: number; } + + /** + * The extension context class of input method. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + class InputMethodExtensionContext extends ExtensionContext { + + /** + * Information of an extension ability. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + */ + abilityInfo: ExtensionAbilityInfo; + + /** + * Input method extension uses this method to start a specific ability. + * + * @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; + + /** + * Input method extension uses this method to start a specific ability with account. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the ability to start. + * @param accountId Indicates the accountId to start. + * @param options Indicates the start options. + * @return - + * @StageModelOnly + */ + startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + + /** + * Connects an ability to an input method extension. + * + *

This method can be called by an ability or input method extension, but the destination of the connection must be an + * input method extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target + * input method extension when the input method extension is connected.

+ * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the service extension to connect. + * @param options Indicates the callback of connection. + * @return connection id, int value. + * @StageModelOnly + */ + connectAbility(want: Want, options: ConnectOptions): number; + + /** + * Connects an ability to an input method extension with account. + * + *

This method can be called by an ability or input method extension, but the destination of the connection must be an + * input method extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target + * input method extension when the input method extension is connected.

+ * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the service extension to connect. + * @param accountId Indicates the account to connect. + * @param options Indicates the callback of connection. + * @return connection id, int value. + * @StageModelOnly + */ + connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + + /** + * Disconnects an ability to an input method extension, in contrast to + * {@link connectAbility}. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param connection the connection id returned from connectAbility api. + * @return - + * @StageModelOnly + */ + disconnectAbility(connection: number, callback:AsyncCallback): void; + disconnectAbility(connection: number): Promise; + + /** + * Destroy the input method extension. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @return - + * @StageModelOnly + */ + terminateSelf(callback: AsyncCallback): void; + terminateSelf(): Promise; + + } + + /** + * The extension ability class of input method. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + class InputMethodExtensionAbility { + + /** + * Indicates input method extension ability context. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @StageModelOnly + */ + context: InputMethodExtensionContext; + + /** + * Called back when a input method extension is started for initialization. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @param want Indicates the want of created service extension. + * @return - + * @StageModelOnly + */ + onCreate(want: Want): void; + + /** + * Called back before a input method extension is destroyed. + * + * @since 9 + * @syscap SystemCapability.MiscServices.InputMethodFramework + * @return - + * @StageModelOnly + */ + onDestroy(): void; + + } } export default inputMethodEngine;