如何查看触摸热区范围

如何查看触摸热区范围

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 }) 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
分享
微博
QQ
微信
回复
2024-07-22 20:11:50
相关问题
Progress触摸增大demo
1526浏览 • 1回复 待解决
HarmonyOS如何增加控件点击
1254浏览 • 1回复 待解决
HarmonyOS TabBar事件处理
843浏览 • 1回复 待解决
请问重载如何启动?
354浏览 • 0回复 待解决
PolarDB增加存储可用如何操作?
3425浏览 • 1回复 待解决
如何设置组件的尺寸范围
958浏览 • 1回复 待解决
HarmonyOS 子组件如何拦截触摸事件
836浏览 • 1回复 待解决
HarmonyOS 更新咨询
921浏览 • 1回复 待解决
触摸TextInput组件的背景颜色如何更改
1595浏览 • 1回复 待解决
HarmonyOS 修复,图表组件
802浏览 • 1回复 待解决
鸿蒙响应屏幕触摸事件如何获取?
8318浏览 • 1回复 已解决
求大佬告知如何屏蔽触摸事件
1474浏览 • 1回复 待解决
重载该如何实现?有人知道吗?
1354浏览 • 1回复 待解决
半模态弹窗如何禁止两边触摸
913浏览 • 0回复 待解决
HarmonyOS 修复方案
920浏览 • 1回复 待解决
如何去实现部分har页面的更新
1126浏览 • 1回复 待解决
如何查看AdsKitService版本
3260浏览 • 1回复 待解决
HarmonyOS 修复技术方案咨询
1092浏览 • 1回复 待解决
HarmonyOS so的修复能力
1204浏览 • 1回复 待解决
如何找出Redis中的大Key与Key?
3547浏览 • 1回复 待解决