• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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/// <reference path="../component/common.d.ts" />
17
18import type { AsyncCallback } from './@ohos.base';
19import type unifiedDataChannel from './@ohos.data.unifiedDataChannel';
20import type { CustomBuilder, DragItemInfo, DragEvent } from 'DragControllerParam';
21
22/**
23 * This module allows developers to trigger a drag event.
24 * @namespace dragController
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @since 10
27 */
28declare namespace dragController {
29  /**
30   * DragInfo object description
31   *
32   * @interface DragInfo
33   * @syscap SystemCapability.ArkUI.ArkUI.Full
34   * @since 10
35   */
36  interface DragInfo {
37    /**
38     * A unique identifier to identify which touch point.
39     * @type { number }
40     * @syscap SystemCapability.ArkUI.ArkUI.Full
41     * @since 10
42     */
43    pointerId: number;
44
45    /**
46    * Drag data.
47    * @type { ?unifiedDataChannel.UnifiedData }
48    * @syscap SystemCapability.ArkUI.ArkUI.Full
49    * @since 10
50    */
51    data?: unifiedDataChannel.UnifiedData;
52
53    /**
54    * Additional information about the drag info.
55    * @type { ?string }
56    * @syscap SystemCapability.ArkUI.ArkUI.Full
57    * @since 10
58    */
59    extraParams?: string;
60  }
61
62  /**
63   * Execute a drag event.
64   * @param { CustomBuilder | DragItemInfo } custom - Object used for prompts displayed when the object is dragged.
65   * @param { DragInfo } dragInfo - Information about the drag event.
66   * @param { AsyncCallback<{ event: DragEvent, extraParams: string }> } callback - Callback that contains the drag event information.
67   * @syscap SystemCapability.ArkUI.ArkUI.Full
68   * @since 10
69   */
70  function executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo, callback: AsyncCallback<{
71    event: DragEvent, extraParams: string
72  }>): void;
73
74  /**
75   * Execute a drag event.
76   * @param { CustomBuilder | DragItemInfo } custom - Object used for prompts displayed when the object is dragged.
77   * @param { DragInfo } dragInfo - Information about the drag event.
78   * @returns { Promise<{ event: DragEvent, extraParams: string }> } A Promise with the drag event information.
79   * @syscap SystemCapability.ArkUI.ArkUI.Full
80   * @since 10
81   */
82  function executeDrag(custom: CustomBuilder | DragItemInfo, dragInfo: DragInfo): Promise<{
83    event: DragEvent, extraParams: string
84  }>;
85}
86
87export default dragController;
88