1# 点击控制 2 3> **说明:** 4> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 5 6 7## 权限列表 8 9无 10 11 12## 属性 13 14 15| **名称** | **参数类型** | **默认值** | **描述** | 16| --------- | -------- | ------- | -------------- | 17| touchable | boolean | true | 设置当前组件是否可以响应点击事件、触摸事件等手指交互事件。 | 18 19 20## 示例 21 22```ts 23// xxx.ets 24@Entry 25@Component 26struct TouchAbleExample { 27 @State text1: string = '' 28 @State text2: string = '' 29 30 build() { 31 Stack() { 32 Rect() 33 .fill(Color.Gray).width(150).height(150) 34 .onClick(() => { 35 console.info(this.text1 = 'Rect Clicked') 36 }) 37 .overlay(this.text1, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 38 Ellipse() 39 .fill(Color.Pink).width(150).height(80) 40 .touchable(false) // 点击Ellipse区域,不会打印 “Ellipse Clicked” 41 .onClick(() => { 42 console.info(this.text2 = 'Ellipse Clicked') 43 }) 44 .overlay(this.text2, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 45 }.margin(100) 46 } 47} 48``` 49 50 51 52