HarmonyOS 如何查看responseRegion设置的触摸热区范围?

HarmonyOS 如何查看responseRegion设置的触摸热区范围?

HarmonyOS
2024-11-26 09:13:12
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Excelsior_abit

目前只能通过自定义的方式获取responseRegion。

@Entry 
@Component 
struct TouchTargetExample { 
  @State text: string = "" 
  @State x:number = 0 
  @State y:number = 0 
  @State reg_width:string = '10%' 
  @State reg_height:string = '100%' 
 
  build() { 
    Column({ space: 20 }) { 
      Text("{x:0,y:0,width:'50%',height:'100%'}") 
 
      // 热区宽度为按钮的一半,点击右侧无响应 
      Button("button1") 
        .responseRegion({ x: this.x, y: this.y, width: this.reg_width, height: this.reg_height }) 
        .onClick(() => { 
          this.text = 'button1 clicked' 
          console.log('button1 clicked: '+this.x+' '+this.y+' '+this.reg_width+' '+this.reg_height) 
        }) 
 
      Text(this.text).margin({ top: 10 }) 
    }.width('100%').margin({ top: 100 }) 
  } 
}
分享
微博
QQ
微信
回复
2024-11-26 15:10:58
相关问题
如何查看触摸范围
1137浏览 • 1回复 待解决
Progress触摸增大demo
1686浏览 • 1回复 待解决
HarmonyOS如何增加控件点击
1646浏览 • 1回复 待解决
HarmonyOS TabBar事件处理
1035浏览 • 1回复 待解决
HarmonyOS responseRegion
879浏览 • 1回复 待解决
如何设置组件尺寸范围
1135浏览 • 1回复 待解决
TimePicker如何设置时间选择器范围
8031浏览 • 1回复 待解决
PolarDB增加存储可用如何操作?
3561浏览 • 1回复 待解决
HarmonyOS so修复能力
1422浏览 • 1回复 待解决
HarmonyOS 触摸事件冲突问题
868浏览 • 1回复 待解决
请问重载如何启动?
556浏览 • 0回复 待解决
HarmonyOS 更新咨询
1168浏览 • 1回复 待解决
HarmonyOS 子组件如何拦截触摸事件
1165浏览 • 1回复 待解决
触摸TextInput组件背景颜色如何更改
2020浏览 • 1回复 待解决
HarmonyOS 触摸手势相关问题
775浏览 • 1回复 待解决
HarmonyOS flingSpeedLimit 范围是多少
1161浏览 • 1回复 待解决
HarmonyOS 修复方案
1229浏览 • 1回复 待解决