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
相关问题
如何查看触摸范围
514浏览 • 1回复 待解决
Progress触摸增大demo
1090浏览 • 1回复 待解决
HarmonyOS如何增加控件点击
768浏览 • 1回复 待解决
HarmonyOS TabBar事件处理
242浏览 • 1回复 待解决
HarmonyOS responseRegion
331浏览 • 1回复 待解决
如何设置组件尺寸范围
570浏览 • 1回复 待解决
TimePicker如何设置时间选择器范围
7223浏览 • 1回复 待解决
HarmonyOS so修复能力
677浏览 • 1回复 待解决
HarmonyOS 更新咨询
227浏览 • 1回复 待解决
HarmonyOS 修复方案
63浏览 • 1回复 待解决
HarmonyOS 子组件如何拦截触摸事件
237浏览 • 1回复 待解决
触摸TextInput组件背景颜色如何更改
995浏览 • 1回复 待解决
PolarDB增加存储可用如何操作?
2970浏览 • 1回复 待解决
HarmonyOS 触摸事件冲突问题
163浏览 • 1回复 待解决
HarmonyOS 修复,图表组件
220浏览 • 1回复 待解决
HarmonyOS RN侧编译问题
375浏览 • 1回复 待解决
HarmonyOS App是否支持更新?
341浏览 • 1回复 待解决
如何查看HarmonyOSAPI文档
10994浏览 • 1回复 待解决