未验证 提交 028566f5 编写于 作者: O openharmony_ci 提交者: Gitee

!9625 【ACE子系统】新增接口用例挑单Beta2

Merge pull request !9625 from 王旭鹏/cherry-pick-1690799847
/**
* Copyright (c) 2023 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 dragController from "@ohos.arkui.dragController"
import UDMF from '@ohos.data.UDMF';
import componentSnapshot from '@ohos.arkui.componentSnapshot';
import image from '@ohos.multimedia.image';
@Entry
@Component
struct DragController1 {
@State pixmap: image.PixelMap = null
@Builder DraggingBuilder() {
Column() {
Text("DraggingBuilder")
}
.width(100)
.height(100)
.backgroundColor(Color.Blue)
}
@Builder PixmapBuilder() {
Column() {
Text("PixmapBuilder")
}
.width(100)
.height(100)
.backgroundColor(Color.Blue)
}
build() {
Column() {
Button('touch to execute drag')
.onTouch((event) => {
if (event.type == TouchType.Down) {
let text = new UDMF.Text()
let unifiedData = new UDMF.UnifiedData(text)
let dragInfo: dragController.DragInfo = {
pointerId: 0,
data: unifiedData,
extraParams: ''
}
componentSnapshot.createFromBuilder(this.PixmapBuilder.bind(this)).then((pix: image.PixelMap) => {
this.pixmap = pix;
let dragItemInfo: DragItemInfo = {
pixelMap: this.pixmap,
builder: this.DraggingBuilder.bind(this),
extraInfo: "DragItemInfoTest"
}
dragController.executeDrag(dragItemInfo, dragInfo)
.then(({event, extraParams}) => {
if (event.getResult() == DragRet.DRAG_SUCCESS) {
// ...
} else if (event.getResult() == DragRet.DRAG_FAILED) {
// ...
}
})
.catch((err) => {
})
})
}
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
......@@ -90,6 +90,7 @@
"MainAbility/pages/Xcomponent",
"MainAbility/pages/RouteType1",
"MainAbility/pages/RouteType2",
"MainAbility/pages/navition3"
"MainAbility/pages/navition3",
"MainAbility/pages/DragController"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册