1e41f4b71Sopenharmony_ci# Event Distribution 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Overview 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciArkUI touch events are primarily categorized into touch and mouse types based on the input source. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciThe touch input sources include: finger, pen 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciThe mouse input sources include: mouse, touchpad, joystick 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciEvents triggered by these two types of input sources are as follows. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci| Touch | Mouse | 14e41f4b71Sopenharmony_ci|:-----:| ----- | 15e41f4b71Sopenharmony_ci| Touch event | Touch event | 16e41f4b71Sopenharmony_ci| Click event | Mouse event | 17e41f4b71Sopenharmony_ci| Drag event | Click event | 18e41f4b71Sopenharmony_ci| Gesture event | Drag event | 19e41f4b71Sopenharmony_ci| | Gesture event | 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciBoth touch and mouse events in ArkUI are initiated by touch testing, which directly determines the generation of the ArkUI event response chain and the distribution of events. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci## Touch Testing 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ciSeveral factors significantly affect the results of touch testing: 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci- **TouchTest**: The entry method for touch testing, without external APIs 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci- **hitTestBehavior**: control on touch testing 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci- **interceptTouch**: custom interception of events 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci- **responseRegion**: touch target settings 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci- **enabled**: enable/disable control, which means control on the component's interactivity 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci- Security components 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci- Other attribute settings: such as opacity and component availability 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci### TouchTest 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci- Touch testing is initiated by each press action, with the root node's **TouchTest** API as the default entry point. 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci- **hitTestBehavior** can be modified by the **InterceptTouch** event. 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci- If touch targets, enable/disable control, opacity, or other settings do not meet the component's interaction requirements, the event will immediately bubble up to the parent node. 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci  50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci### Touch Test Control 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ciFor details, see [Hit Test Control](../reference/apis-arkui/arkui-ts/ts-universal-attributes-hit-test-behavior.md). 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci- Hit: The touch test successfully captures events for the current component or its child components. 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci- The impact of child components on the parent component's touch test depends on the last child component that does not block the touch test. 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci- **HitTestMode.Default**: the default mode when the **hitTestBehavior** attribute is not specified. If the component itself is hit, it will block other siblings but not children. 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci  62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci- **HitTestMode.None**: The component does not receive events and does not prevent siblings or children from continuing the touch test. 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci  66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci- **HitTestMode.Block**: This mode blocks touch tests of the children. If the component itself is hit, it will block the touch test for siblings and the parent. 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci  70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci- **HitTestMode.Transparent**: The component participates in the touch test without blocking siblings or the parent. 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci  74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci### Custom Event Interception 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci[Custom event interception](../reference/apis-arkui/arkui-ts/ts-universal-attributes-on-touch-intercept.md) allows you to dynamically change a component's **hitTestBehavior** attribute based on service needs when a touch is initiated. 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci### Enable/Disable Control 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci[Disabled](../reference/apis-arkui/arkui-ts/ts-universal-attributes-enable.md) components, including their children, do not initiate the touch testing process; instead, they pass the event back to the parent for handling. 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci### Touch Target Settings 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci[Touch target settings](../reference/apis-arkui/arkui-ts/ts-universal-attributes-touch-target.md) affect touch testing for touch and mouse inputs. If the component area is set to zero or designated as a non-touchable area, the event will directly propagate to the parent node for continued touch testing. 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci### Security Components 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ciArkUI provides a range of security components, including [LocationButton](../security/AccessToken/locationbutton.md), [PasteButton](../security/AccessToken/pastebutton.md), and [SaveButton](../security/AccessToken/savebutton.md). 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ciIf a component has a higher [z-order](../reference/apis-arkui/arkui-ts/ts-universal-attributes-z-order.md) than a security component and covers it, the security component's touch events are sent directly to the parent node for further touch testing. 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci## Event Response Chain Collection 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ciIn ArkUI, the event response chain is collected based on a right subtree priority, which follows a post-order traversal process according to the layout hierarchy of components. The process is as follows: 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci``` 98e41f4b71Sopenharmony_ciforeach(item=>(node.rbegin(),node.rend(){ 99e41f4b71Sopenharmony_ci item.TouchTest() 100e41f4b71Sopenharmony_ci} 101e41f4b71Sopenharmony_cinode.collectEvent() 102e41f4b71Sopenharmony_ci``` 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ciIn the example of response chain collection below, with all **hitTestBehavior** attributes set to **Default** in the component tree, if a user touches component 5, the response chain that is ultimately collected, in order, is 5, 3, 1. 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ciThis is because component 3 has **hitTestBehavior** set to **Default**, which, upon capturing the event, blocks the collection from its sibling nodes, thereby preventing the collection of component 1's left subtree. 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci  109