如何用微信打开微网站,云南网站设计公司,aspnet网站开发选择题,wordpress主题jenney最近对image 设置长按事件#xff0c;通过api发现有个长按事件 LongPressGesture#xff0c;但是使用了长按没反应#xff0c;于是看文档#xff0c;文档描述如下#xff1a;
当组件默认支持可拖拽时#xff0c;如Text、TextInput、TextArea、HyperLink、Image和RichEd…最近对image 设置长按事件通过api发现有个长按事件 LongPressGesture但是使用了长按没反应于是看文档文档描述如下
当组件默认支持可拖拽时如Text、TextInput、TextArea、HyperLink、Image和RichEditor等组件。长按手势与拖拽会出现冲突事件优先级如下
长按触发时间 500ms长按事件优先拖拽事件响应。
长按触发时间 500ms拖拽事件优先长按事件响应。
那心想是不是事件冲突为了保证长按事件可以禁掉别的事件是不是就可以经过验证是可以的设置draggable(false)就ok了。
Entry
Component
export struct FirstPage {build() {Column() {Text(测试image长按事件).margin({ bottom: 15 })Image($r(app.media.app_icon)).width(60).height(60).draggable(false) //Image组件默认是可拖拽的给Image组件设置draggable为false.gesture(LongPressGesture({ repeat: true }).onAction((event?: GestureEvent) {if (event) {console.log(FirstPage 收到了事件了吗)}}))}.width(100%).height(100%).justifyContent(FlexAlign.Center).alignItems(HorizontalAlign.Center)}
}