1# Custom Event Interception 2 3The custom event interception capability provided for components lets you determine the **HitTestMode** attribute of a component based on the position where the event is triggered on the component, and 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 27```ts 28// xxx.ets 29@Entry 30@Component 31struct Index { 32 isPolygon(event: TouchEvent) { 33 return true; 34 } 35 36 build(){ 37 Row(){ 38 Column(){ 39 Text("hello world") 40 .backgroundColor(Color.Blue) 41 .fontSize(50) 42 .fontWeight(FontWeight.Bold) 43 .onClick(()=>{ 44 console.log("Text click"); 45 }) 46 } 47 .width(400) 48 .height(300) 49 .backgroundColor(Color.Pink) 50 .onClick(()=>{ 51 console.log("Column click"); 52 }) 53 // Call onTouchIntercept to modify the HitTestMode attribute of the component. 54 .onTouchIntercept((event : TouchEvent) => { 55 console.log("OnTouchIntercept + " + JSON.stringify(event)); 56 if (this.isPolygon(event)) { 57 return HitTestMode.None 58 } 59 return HitTestMode.Default 60 }) 61 } 62 .width('100%') 63 } 64} 65``` 66