1e41f4b71Sopenharmony_ci# Defining Gesture Events 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciA gesture represents a semantic action (for example, touch, click, or longpress) that can trigger one or more events. A gesture lifecycle may consist of multiple events from the start to the end of the gesture. Supported events are as follows: 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci**Touch** 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci- **touchstart**: Triggered when the touch starts. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci- **touchmove**: Triggered when the touch moves. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci- **touchcancel**: Triggered when the touch is interrupted, for example, by an incoming call notification or pop-up message. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci- **touchend**: Triggered when the touch ends. 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci**Click** 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**click**: Triggered when a user taps the screen quickly. 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**Longpress** 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**longpress**: Triggered when a user keeps tapping the screen at the same position for a while. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciThe following is an example: 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci```html 26e41f4b71Sopenharmony_ci<!-- xxx.hml --> 27e41f4b71Sopenharmony_ci<div class="container"> 28e41f4b71Sopenharmony_ci <div class="text-container" onclick="click"> 29e41f4b71Sopenharmony_ci <text class="text-style">{{onClick}}</text> 30e41f4b71Sopenharmony_ci </div> 31e41f4b71Sopenharmony_ci <div class="text-container" ontouchstart="touchStart"> 32e41f4b71Sopenharmony_ci <text class="text-style">{{touchstart}}</text> 33e41f4b71Sopenharmony_ci </div> 34e41f4b71Sopenharmony_ci <div class="text-container" ontouchmove="touchMove"> 35e41f4b71Sopenharmony_ci <text class="text-style">{{touchmove}}</text> 36e41f4b71Sopenharmony_ci </div> 37e41f4b71Sopenharmony_ci <div class="text-container" ontouchend="touchEnd"> 38e41f4b71Sopenharmony_ci <text class="text-style">{{touchend}}</text> 39e41f4b71Sopenharmony_ci </div> 40e41f4b71Sopenharmony_ci <div class="text-container" ontouchcancel="touchCancel"> 41e41f4b71Sopenharmony_ci <text class="text-style">{{touchcancel}}</text> 42e41f4b71Sopenharmony_ci </div> 43e41f4b71Sopenharmony_ci <div class="text-container" onlongpress="longPress"> 44e41f4b71Sopenharmony_ci <text class="text-style">{{onLongPress}}</text> 45e41f4b71Sopenharmony_ci </div> 46e41f4b71Sopenharmony_ci</div> 47e41f4b71Sopenharmony_ci``` 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci```css 50e41f4b71Sopenharmony_ci/* xxx.css */ 51e41f4b71Sopenharmony_ci.container { 52e41f4b71Sopenharmony_ci width: 100%; 53e41f4b71Sopenharmony_ci height: 100%; 54e41f4b71Sopenharmony_ci flex-direction: column; 55e41f4b71Sopenharmony_ci justify-content: center; 56e41f4b71Sopenharmony_ci align-items: center; 57e41f4b71Sopenharmony_ci} 58e41f4b71Sopenharmony_ci.text-container { 59e41f4b71Sopenharmony_ci margin-top: 30px; 60e41f4b71Sopenharmony_ci flex-direction: column; 61e41f4b71Sopenharmony_ci width: 600px; 62e41f4b71Sopenharmony_ci height: 70px; 63e41f4b71Sopenharmony_ci background-color: #0000FF; 64e41f4b71Sopenharmony_ci} 65e41f4b71Sopenharmony_ci.text-style { 66e41f4b71Sopenharmony_ci width: 100%; 67e41f4b71Sopenharmony_ci line-height: 50px; 68e41f4b71Sopenharmony_ci text-align: center; 69e41f4b71Sopenharmony_ci font-size: 24px; 70e41f4b71Sopenharmony_ci color: #ffffff; 71e41f4b71Sopenharmony_ci} 72e41f4b71Sopenharmony_ci``` 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci```js 75e41f4b71Sopenharmony_ci// xxx.js 76e41f4b71Sopenharmony_ciexport default { 77e41f4b71Sopenharmony_ci data: { 78e41f4b71Sopenharmony_ci touchstart: 'touchstart', 79e41f4b71Sopenharmony_ci touchmove: 'touchmove', 80e41f4b71Sopenharmony_ci touchend: 'touchend', 81e41f4b71Sopenharmony_ci touchcancel: 'touchcancel', 82e41f4b71Sopenharmony_ci onClick: 'onclick', 83e41f4b71Sopenharmony_ci onLongPress: 'onlongpress', 84e41f4b71Sopenharmony_ci }, 85e41f4b71Sopenharmony_ci touchCancel: function (event) { 86e41f4b71Sopenharmony_ci this.touchcancel = 'canceled'; 87e41f4b71Sopenharmony_ci }, 88e41f4b71Sopenharmony_ci touchEnd: function(event) { 89e41f4b71Sopenharmony_ci this.touchend = 'ended'; 90e41f4b71Sopenharmony_ci }, 91e41f4b71Sopenharmony_ci touchMove: function(event) { 92e41f4b71Sopenharmony_ci this.touchmove = 'moved'; 93e41f4b71Sopenharmony_ci }, 94e41f4b71Sopenharmony_ci touchStart: function(event) { 95e41f4b71Sopenharmony_ci this.touchstart = 'touched'; 96e41f4b71Sopenharmony_ci }, 97e41f4b71Sopenharmony_ci longPress: function() { 98e41f4b71Sopenharmony_ci this.onLongPress = 'longpressed'; 99e41f4b71Sopenharmony_ci }, 100e41f4b71Sopenharmony_ci click: function() { 101e41f4b71Sopenharmony_ci this.onClick = 'clicked'; 102e41f4b71Sopenharmony_ci }, 103e41f4b71Sopenharmony_ci} 104e41f4b71Sopenharmony_ci``` 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci