新聞中心
事件主要包括手勢事件和按鍵事件。手勢事件主要用于智能穿戴等具有觸摸屏的設(shè)備,按鍵事件主要用于智慧屏設(shè)備。

公司主營業(yè)務(wù):成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。成都創(chuàng)新互聯(lián)是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。成都創(chuàng)新互聯(lián)推出播州免費做網(wǎng)站回饋大家。
手勢事件
手勢表示由單個或多個事件識別的語義動作(例如:點擊、拖動和長按)。一個完整的手勢也可能由多個事件組成,對應(yīng)手勢的生命周期。JS UI 框架支持的手勢事件有:
觸摸
- touchstart:手指觸摸動作開始。
- touchmove:手指觸摸后移動。
- touchcancel:手指觸摸動作被打斷,如來電提醒、彈窗。
- touchend:手指觸摸動作結(jié)束。
點擊
click:用戶快速輕敲屏幕。
長按
longpress:用戶在相同位置長時間保持與屏幕接觸。
具體的使用示例如下:
{{onclick}}
{{touchStart}}
{{touchMove}}
{{touchEnd}}
{{touchCancel}}
{{onLongPress}}
/* xxx.css */
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.text-container {
padding-top: 10px;
flex-direction: column;
}
.text-style {
padding-top: 20px;
padding-left: 100px;
width: 750px;
height: 100px;
text-align: center;
font-size: 50px;
color: #ffffff;
background-color: #09ba07;
}
// xxx.js
export default {
data: {
textData: '',
touchStart: 'touchstart',
touchMove: 'touchmove',
touchEnd: 'touchend',
touchCancel: 'touchcancel',
onClick: 'onclick',
onLongPress: 'onlongpress',
},
onInit() {
this.textData = 'initdata';
},
onReady: function () {},
onShow: function () {},
onHide: function () {},
onDestroy: function () {},
touchCancel: function (event) {
this.touchCancel = 'canceled';
},
touchEnd: function(event) {
this.touchEnd = 'ended';
},
touchMove: function(event) {
this.touchMove = 'moved';
},
touchStart: function(event) {
this.touchStart = 'touched';
},
longPress: function() {
this.onLongPress = 'longpressed';
},
click: function() {
this.onClick = 'clicked';
},
}
按鍵事件
按鍵事件是智慧屏上特有的手勢事件,當用戶操作遙控器按鍵時觸發(fā)。用戶點擊一個遙控器按鍵,通常會觸發(fā)兩次 key 事件:先觸發(fā) action 為 0,再觸發(fā) action 為 1,即先觸發(fā)按下事件,再觸發(fā)抬起事件。action 為 2 的場景比較少見,一般為用戶按下按鍵且不松開,此時 repeatCount 將返回次數(shù)。每個物理按鍵對應(yīng)各自的按鍵值(keycode)以實現(xiàn)不同的功能,常用的按鍵值請參考組件通用事件。具體的使用示例如下:
{{up}}
{{down}}
/* xxx.css */
.card-box {
flex-direction: column;
justify-content: center;
}
.content-box {
align-items: center;
height: 200px;
flex-direction: column;
margin-left: 200px;
margin-right: 200px;
}
.content-text {
font-size: 40px;
text-align: center;
}
// xxx.js
export default {
data: {
up: 'up',
down: 'down',
},
focusUp: function() {
this.up = 'up focused';
},
blurUp: function() {
this.up = 'up';
},
keyUp: function() {
this.up = 'up keyed';
},
focusDown: function() {
this.down = 'down focused';
},
blurDown: function() {
this.down = 'down';
},
keyDown: function() {
this.down = 'down keyed';
},
}按鍵事件通過獲焦事件向下分發(fā),因此示例中使用了 focus 事件和 blur 事件明確當前焦點的位置。點按上下鍵選中 up 或 down 按鍵,即相應(yīng)的 focused 狀態(tài),失去焦點的按鍵恢復(fù)正常的 up 或 down 按鍵文本。按確認鍵后該按鍵變?yōu)?keyed 狀態(tài)。
本文題目:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OS事件
新聞來源:http://www.5511xx.com/article/djcpgid.html


咨詢
建站咨詢
