From 862c01b6612869e5e5ddf9094f1eea15f72ecd6a Mon Sep 17 00:00:00 2001 From: hwyml Date: Tue, 17 Jun 2025 16:37:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=92=E8=AF=8D?= =?UTF-8?q?=E6=A1=86=E6=9E=B6API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hwyml --- api/@ohos.selectionInput.SelectionPanel.d.ts | 101 +++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 api/@ohos.selectionInput.SelectionPanel.d.ts diff --git a/api/@ohos.selectionInput.SelectionPanel.d.ts b/api/@ohos.selectionInput.SelectionPanel.d.ts new file mode 100644 index 0000000000..b5e701d27b --- /dev/null +++ b/api/@ohos.selectionInput.SelectionPanel.d.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025 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. + */ + +/** + * @file + * @kit BasicServicesKit + */ + +/** + * Defines information about the word selection panel. + * @typedef PanelInfo + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + +export interface PanelInfo { + /** + * Type of the word selection panel. + * @type { PanelType } + * @default MENU + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + panelType: PanelType; + + /** + * X-coordinate of the upper left corner of the word selection panel on the screen. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + x: int; + + /** + * Y-coordinate of the upper left corner of the word selection panel on the screen. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + y: int; + + /** + * Width of the word selection panel. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + width: int; + + /** + * Height of the word selection panel. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + height: int; +} + +/** + * Enumerates the types of the word selection panel. + * @enum { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + +export enum PanelType { + /** + * Menu panel. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + MENU_PANEL = 1, + + /** + * Main panel. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + MAIN_PANEL = 2 +} \ No newline at end of file -- Gitee From 9334e3db0d562af2016ff125bd806029a5c41f6e Mon Sep 17 00:00:00 2001 From: hwyml Date: Tue, 17 Jun 2025 16:38:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=92=E8=AF=8D?= =?UTF-8?q?=E6=A1=86=E6=9E=B6API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hwyml --- ...@ohos.selectionInput.selectionManager.d.ts | 353 ++++++++++++++++++ 1 file changed, 353 insertions(+) create mode 100644 api/@ohos.selectionInput.selectionManager.d.ts diff --git a/api/@ohos.selectionInput.selectionManager.d.ts b/api/@ohos.selectionInput.selectionManager.d.ts new file mode 100644 index 0000000000..a2ce43706c --- /dev/null +++ b/api/@ohos.selectionInput.selectionManager.d.ts @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2025 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. + */ + +/** + * @file + * @kit BasicServicesKit + */ + +import type { Callback } from './@ohos.base'; +import type Context from './application/Context'; +import type { PanelInfo } from './@ohos.selectionInput.SelectionPanel'; + +/** + * Declares the selectionManager for listening for word selection events and managing word selection panels. + * @namespace selectionManager + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + +declare namespace selectionManager { + /** + * Registers a callback to listen for the word selection completion event. + * @param { 'selectionCompleted' } type Word selection completion event. + * @param { Callback } callback Callback used to listen for the word selection completion + * event. + * @throws { BusinessError } 33600003 Invalid operation. The selection app is not valid. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + function on(type: 'selectionCompleted', callback: Callback): void; + + /** + * Unregisters the callback used to listen for the word selection completion event. + * @param { 'selectionCompleted' } type Word selection completion event. + * @param { Callback } [callback] (Optional) Callback used to listen for the word selection + * completion event. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + function off(type: 'selectionCompleted', callback?: Callback): void; + + /** + * Creates a word selection panel. + * @param { Context } ctx Context on which the word selection panel depends. + * @param { PanelInfo } info Information about the word selection panel. + * @returns { Promise } Promise used to return the word selection panel. + * @throws { BusinessError } 33600001 Selection service exception. + * @throws { BusinessError } 33600003 Invalid operation. The selection app is not valid. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + function createPanel(ctx: Context, info: PanelInfo): Promise; + + /** + * Destroys the word selection panel. + * @param { Panel } panel Word selection panel. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 33600001 Selection service exception. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + function destroyPanel(panel: Panel): Promise; + + /** + * Defines the information of a word selection event. + * @typedef SelectionInfo + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + interface SelectionInfo { + /** + * Selected text. + * @type { string } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + text: string; + + /** + * Operation for selecting words. + * @type { SelectionType } + * @default MOUSE_MOVE + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + selectionType: SelectionType; + + /** + * X-coordinate of the screen where the word selection starts. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + startDisplayX: int; + + /** + * Y-coordinate of the screen where the word selection starts. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + startDisplayY: int; + + /** + * X-coordinate of the screen where the word selection ends. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + endDisplayX: int; + + /** + * Y-coordinate of the screen where the word selection ends. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + endDisplayY: int; + + /** + * X-coordinate of the window where the word selection starts. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + startWindowX: int; + + /** + * Y-coordinate of the window where the word selection starts. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + startWindowY: int; + + /** + * X-coordinate of the window where the word selection ends. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + endWindowX: int; + + /** + * Y-coordinate of the window where the word selection ends. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + endWindowY: int; + + /** + * ID of the screen where the window with selected words is located. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + displayID: int; + + /** + * ID of the window where words are selected. + * @type { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + windowID: int; + + /** + * Bundle name of the application where words are selected. + * @type { string } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + bundleName: string; + } + + /** + * Defines a word selection panel. + * @typedef Panel + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + interface Panel { + /** + * Sets the content to be displayed in the panel. + * @param { string } path Path of the content to be displayed. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 33600001 Selection service exception. + * @throws { BusinessError } 33600002 This selection window has been destroyed. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + setUiContent(path: string): Promise; + + /** + * Shows this word selection panel. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 33600001 Selection service exception. + * @throws { BusinessError } 33600002 This selection window has been destroyed. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + show(): Promise; + + /** + * Hides this word selection panel. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 33600001 Selection service exception. + * @throws { BusinessError } 33600002 This selection window has been destroyed. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + hide(): Promise; + + /** + * Moves the word selection panel by dragging. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 33600001 Selection service exception. + * @throws { BusinessError } 33600002 This selection window has been destroyed. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + startMoving(): Promise; + + /** + * Moves the word selection panel to the specified coordinates on the screen. + * @param { int } x X-coordinate on the screen. + * @param { int } y Y-coordinate on the screen. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 33600001 Selection service exception. + * @throws { BusinessError } 33600002 This selection window has been destroyed. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + moveTo(x: int, y: int): Promise; + + /** + * Registers a callback to listen for the destroy event of the word selection panel. + * @param { 'destroyed' } type Destroy event of the word selection panel. + * @param { Callback } callback Callback used to listen for the destroy event of the word selection + * panel. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + on(type: 'destroyed', callback: Callback): void; + + /** + * Unregisters the callback used to listen for the destroy event of the word selection panel. + * @param { 'destroyed' } type Destroy event of the word selection panel. + * @param { Callback } [callback] Callback used to listen for the destroy event of the word + * selection panel. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + off(type: 'destroyed', callback?: Callback): void; + + /** + * Registers a callback to listen for the hide event of the word selection panel. + * @param { 'hidden' } type Hide event of the word selection panel. + * @param { Callback } callback Callback used to listen for the hide event of the word selection + * panel. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + on(type: 'hidden', callback: Callback): void; + + /** + * Unregisters the callback used to listen for the hide event of the word selection panel. + * @param { 'hidden' } type Hide event of the word selection panel. + * @param { Callback } [callback] Callback used to listen for the hide event of the word selection + * panel. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + off(type: 'hidden', callback?: Callback): void; + } + + /** + * Enumerates the operations for selecting words. + * @enum { int } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + enum SelectionType { + /** + * Move the cursor to select words. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + MOUSE_MOVE = 1, + + /** + * Double-click to select words. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + DOUBLE_CLICK = 2, + + /** + * Triple-click to select words. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + TRIPLE_CLICK = 3 + } +} + +export default selectionManager; \ No newline at end of file -- Gitee From 1b1c54295b7815c173fedf9762261e1840d7c2e3 Mon Sep 17 00:00:00 2001 From: hwyml Date: Tue, 17 Jun 2025 16:43:44 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=92=E8=AF=8D?= =?UTF-8?q?=E6=A1=86=E6=9E=B6API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hwyml --- ...ectionInput.SelectionExtensionAbility.d.ts | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 api/@ohos.selectionInput.SelectionExtensionAbility.d.ts diff --git a/api/@ohos.selectionInput.SelectionExtensionAbility.d.ts b/api/@ohos.selectionInput.SelectionExtensionAbility.d.ts new file mode 100644 index 0000000000..d19ce239b4 --- /dev/null +++ b/api/@ohos.selectionInput.SelectionExtensionAbility.d.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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. + */ + +/** + * @file + * @kit BasicServicesKit + */ + +import type rpc from './@ohos.rpc'; +import type Want from './@ohos.app.ability.Want'; +import type ExtensionContext from './application/ExtensionContext'; + +/** + * Defines the class of the ExtensionAbility for word selection. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + +export default class SelectionExtensionAbility { + /** + * Context of the ExtensionAbility. + * @type { ExtensionContext } + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + context: ExtensionContext; + + /** + * Callback invoked when the ExtensionAbility is initialized. + * @param { Want } want Want object used to initialize the ExtensionAbility. + * @returns { rpc.RemoteObject } RPC remote connection object. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + onConnect(want: Want): rpc.RemoteObject; + + /** + * Callback invoked when the ExtensionAbility is disconnected. + * @syscap SystemCapability.SelectionInput.Selection + * @since 20 + * @arkts 1.1&1.2 + */ + onDisconnect(): void; +} \ No newline at end of file -- Gitee