如何查看触摸热区范围

如何查看触摸热区范围

HarmonyOS
2024-07-22 12:29:03
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
kraml

目前只能通过自定义的方式获取responseRegion。参考文档:触摸热区设置

@Entry 
@Component 
struct TouchTargetExample { 
  @State text: string = '' 
  @State x:number = 0 
  @State y:number = 0 
  @State reg_width:string = '50%' 
  @State reg_height:string = '100%' 
 
  build() { 
    Column({ space: 20 }) { 
      Text("{x:0,y:0,width:'50%',height:'100%'}") 
 
      // 热区宽度为按钮的一半,点击右侧无响应 
      Button('button') 
        .responseRegion({ x: this.x, y: this.y, width: this.reg_width, height: this.reg_height }) 
        .onClick(() => { 
          this.text = 'button clicked' 
          console.log('button clicked: '+this.x+' '+this.y+' '+this.reg_width+' '+this.reg_height) 
        }) 
 
      Text(this.text).margin({ top: 10 }) 
    }.width('100%').margin({ top: 100 }) 
  } 
}
分享
微博
QQ
微信
回复
2024-07-22 20:11:50
相关问题
Progress触摸增大demo
904浏览 • 1回复 待解决
HarmonyOS如何增加控件点击
610浏览 • 1回复 待解决
HarmonyOS TabBar事件处理
36浏览 • 1回复 待解决
PolarDB增加存储可用如何操作?
2803浏览 • 1回复 待解决
如何设置组件的尺寸范围
386浏览 • 1回复 待解决
重载该如何实现?有人知道吗?
799浏览 • 1回复 待解决
鸿蒙响应屏幕触摸事件如何获取?
7497浏览 • 1回复 已解决
求大佬告知如何屏蔽触摸事件
708浏览 • 1回复 待解决
HarmonyOS 子组件如何拦截触摸事件
67浏览 • 1回复 待解决
HarmonyOS so的修复能力
524浏览 • 1回复 待解决
HarmonyOS 修复技术方案咨询
204浏览 • 1回复 待解决
如何找出Redis中的大Key与Key?
2760浏览 • 1回复 待解决
有谁知道如何屏蔽触摸事件
1777浏览 • 1回复 待解决
如何查看AdsKitService版本
2492浏览 • 1回复 待解决
触摸TextInput组件的背景颜色如何更改
662浏览 • 1回复 待解决
HarmonyOS 如何查看权限级别?
314浏览 • 1回复 待解决
HarmonyOS 如何查看HCI日志
562浏览 • 1回复 待解决
如何查看OceanBase 集群参数?
3649浏览 • 1回复 待解决
如何去实现部分har页面的更新
383浏览 • 1回复 待解决
HarmonyOS OCR能力范围
188浏览 • 1回复 待解决