From 9d78615890a14a5bf4e46b34e13d5803ce55b4b8 Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Tue, 22 Feb 2022 20:37:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=B3=95js=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyongfei --- api/@ohos.inputmethod.d.ts | 53 ++++++++++++ api/@ohos.inputmethodengine.d.ts | 134 +++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 api/@ohos.inputmethod.d.ts create mode 100644 api/@ohos.inputmethodengine.d.ts diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts new file mode 100644 index 0000000000..c3a8377ebb --- /dev/null +++ b/api/@ohos.inputmethod.d.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 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. + */ + +import {AsyncCallback} from './basic'; + +/** + * inputmethod + * + * @since 8 + * @devices phone, tablet, tv, wearable + */ +declare namespace inputMethod { + const MAX_TYPE_NUM: number + + function getInputMethodSetting(): InputMethodSetting; + + function getInputMethodController(): InputMethodController; + + interface InputMethodSetting { + listInputMethod(callback: AsyncCallback>): void; + + listInputMethod(): Promise>; + + displayOptionalInputMethod(callback: AsyncCallback): void; + + displayOptionalInputMethod(): Promise; + } + + interface InputMethodController { + stopInput(callback: AsyncCallback): void; + + stopInput(): Promise; + } + + interface InputMethodProperty { + readonly packageName: string; + readonly methodId: string; + } +} + +export default inputMethod; diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts new file mode 100644 index 0000000000..81d9099b57 --- /dev/null +++ b/api/@ohos.inputmethodengine.d.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2021 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. + */ + +import {AsyncCallback} from './basic'; + +/** + * inputmethod + * + * @since 8 + * @devices phone, tablet, tv, wearable + */ +declare namespace inputMethodEngine { + const ENTER_KEY_TYPE_UNSPECIFIED: number; + const ENTER_KEY_TYPE_GO: number; + const ENTER_KEY_TYPE_SEARCH: number; + const ENTER_KEY_TYPE_SEND: number; + const ENTER_KEY_TYPE_NEXT: number; + const ENTER_KEY_TYPE_DONE: number; + const ENTER_KEY_TYPE_PREVIOUS: number; + + const PATTERN_NULL: number; + const PATTERN_TEXT: number; + const PATTERN_NUMBER: number; + const PATTERN_PHONE: number; + const PATTERN_DATETIME: number; + const PATTERN_EMAIL: number; + const PATTERN_URI: number; + const PATTERN_PASSWORD: number; + + const FLAG_SELECTING: number; + const FLAG_SINGLE_LINE: number; + + const DISPLAY_MODE_PART: number; + const DISPLAY_MODE_FULL: number; + + const OPTION_ASCII: number; + const OPTION_NONE: number; + const OPTION_AUTO_CAP_CHARACTERS: number; + const OPTION_AUTO_CAP_SENTENCES: number; + const OPTION_AUTO_WORDS: number; + const OPTION_MULTI_LINE: number; + const OPTION_NO_FULLSCREEN: number; + + function getInputMethodEngine(): InputMethodEngine; + + function createKeyboardDelegate(): KeyboardDelegate; + + interface KeyboardController { + hideKeyboard(callbakc: AsyncCallback): void; + + hideKeyboard(): Promise; + } + + interface InputMethodEngine { + on(type: 'inputStart', callback: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; + + off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; + + on(type: 'keyboardShow', callback: () => void): void; + + off(type: 'keyboardShow', callback: () => void): void; + + on(type: 'keyboardHide', callback: () => void): void; + + off(type: 'keyboardHide', callback: () => void): void; + } + + interface TextInputClient { + sendKeyFunction(action: number, callback: AsyncCallback): void; + + sendKeyFunction(action: number): Promise; + + deleteForward(length: number, callback: AsyncCallback): void; + + deleteForward(length: number): Promise; + + deleteBackward(length: number, callback: AsyncCallback): void; + + deleteBackward(length: number): Promise; + + InsertText(text: string, callback: AsyncCallback): void; + + InsertText(text: string): Promise; + + getForward(length: number, callback: AsyncCallback): void; + + getForward(length: number): Promise; + + getEditorAttribute(lcallback: AsyncCallback): void; + + getEditorAttribute(): Promise; + } + + interface KeyboardDelegate { + on(type: 'keyDown', callback: (event: KeyEvent) => boolean): void; + + off(type: 'keyDown', callback?: (event: KeyEvent) => boolean): void; + + on(type: 'keyUp', callback: (event: KeyEvent) => boolean): void; + + off(type: 'keyUp', callback?: (event: KeyEvent) => boolean): void; + + on(type: 'cursorContextChange', callback: (x: number, y: number, height: number) => void): void; + + off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void; + + on(type: 'selectionChange', callback: (oldBegine: number, oldEnd: number, newBegine: number, newEnd: number) => void): void; + + off(type: 'selectionChange', callback?: (oldBegine: number, oldEnd: number, newBegine: number, newEnd: number) => void): void; + + on(type: 'textChange', callback: (text: string) => void): void; + + off(type: 'textChange', callback?: (text: string) => void): void; + } + + interface EditorAttribute { + readonly inputPattern: number; + readonly enterKeyType: number; + } +} + +export default inputMethodEngine; -- Gitee From 92f393e6e7aea153535047acf5615de98a01bf5f Mon Sep 17 00:00:00 2001 From: zhouyongfei Date: Wed, 23 Feb 2022 10:46:20 +0800 Subject: [PATCH 2/2] fix Signed-off-by: zhouyongfei --- api/@ohos.inputmethod.d.ts | 2 +- api/@ohos.inputmethodengine.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index c3a8377ebb..21a0439b5f 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -19,7 +19,7 @@ import {AsyncCallback} from './basic'; * inputmethod * * @since 8 - * @devices phone, tablet, tv, wearable + * @syscap SystemCapability.MiscServices.InputMethod */ declare namespace inputMethod { const MAX_TYPE_NUM: number diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts index 81d9099b57..39b3b83bae 100644 --- a/api/@ohos.inputmethodengine.d.ts +++ b/api/@ohos.inputmethodengine.d.ts @@ -16,10 +16,10 @@ import {AsyncCallback} from './basic'; /** - * inputmethod + * inputmethodengine * * @since 8 - * @devices phone, tablet, tv, wearable + * @syscap SystemCapability.MiscServices.InputMethodEngine */ declare namespace inputMethodEngine { const ENTER_KEY_TYPE_UNSPECIFIED: number; -- Gitee