中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
如何查看触摸热区范围
微信扫码分享
目前只能通过自定义的方式获取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 }) } }
目前只能通过自定义的方式获取responseRegion。参考文档:触摸热区设置