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