1# Custom Event Interception 2 3The custom event interception capability provided for components allows you to dynamically determine the **HitTestMode** attribute of a component based on the position where the event is triggered on the component, as well as other event information such as the input source. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version. 8 9 10## onTouchIntercept 11 12onTouchIntercept(callback: Callback<TouchEvent, HitTestMode>) 13 14**Atomic service API**: This API can be used in atomic services since API version 12. 15 16**System capability**: SystemCapability.ArkUI.ArkUI.Full 17 18**Parameters** 19 20| Name | Type | Mandatory | Description | 21| ---------- | -------------------------- | ------- | ----------------------------- | 22| callback | Callback<[TouchEvent](ts-universal-events-touch.md#touchevent), [HitTestMode](ts-universal-attributes-hit-test-behavior.md#HitTestMode)>| Yes | Custom event interception callback to bind to the component, which is called during hit testing.| 23 24 25## Example 26 27This example demonstrates how to modify the **HitTestMode** attribute of a component using **onTouchIntercept**. 28 29```ts 30// xxx.ets 31@Entry 32@Component 33struct Index { 34 isPolygon(event: TouchEvent) { 35 return true; 36 } 37 38 build(){ 39 Row(){ 40 Column(){ 41 Text("hello world") 42 .backgroundColor(Color.Blue) 43 .fontSize(50) 44 .fontWeight(FontWeight.Bold) 45 .onClick(()=>{ 46 console.log("Text click"); 47 }) 48 } 49 .width(400) 50 .height(300) 51 .backgroundColor(Color.Pink) 52 .onClick(()=>{ 53 console.log("Column click"); 54 }) 55 // Call onTouchIntercept to modify the HitTestMode attribute of the component. 56 .onTouchIntercept((event : TouchEvent) => { 57 console.log("OnTouchIntercept + " + JSON.stringify(event)); 58 if (this.isPolygon(event)) { 59 return HitTestMode.None 60 } 61 return HitTestMode.Default 62 }) 63 } 64 .width('100%') 65 } 66} 67``` 68