import QtQuick 2.0 MouseArea { id:mouseArea property real timerCount: 2000 //default 2s trigger property int preMouseX: 0 //mouse Limit property int preMouseY: 0 //mouse Limit signal longPress() signal longClicked() property bool bBeep: true property int usbformId:0 property int mtpformId:0 property bool longPressFlag: false function mouseAreaMask() { if(true == mouseArea.visible) { mouseArea.visible = false mouseArea.visible = true } } Timer{ id:timer running: false interval: timerCount repeat:false onTriggered: { longPress() } onIntervalChanged: { if(timerCount != 0) { if(true == timer.running) timer.stop() } } } onMouseXChanged: { if(Math.abs(mouseX - preMouseX) <= 20) //offset 20 { if( (mouseX > mouseArea.width) || (mouseX < 0) ) //exit { //console.debug("test exit X" + mouseX) if(timerCount != 0) { if(true == timer.running) timer.stop() } } } preMouseX = mouseX } onMouseYChanged: { if(Math.abs(mouseY - preMouseY) <= 20) { if( (mouseY > mouseArea.height) || (mouseY < 0) ) //exit { //console.debug("test exit Y" + mouseY) if(timerCount != 0) { if(true == timer.running) timer.stop() } } } preMouseY = mouseY } onPressed: { //hmiMiniCtrl.hideHMIBottom() longPressFlag=false preMouseX = mouse.x if (bBeep) acCtrl.touchBeep(0) if(timerCount != 0) { if(true == timer.running) timer.stop() timer.restart() } } onReleased: { if(timerCount != 0) { if(true == timer.running) { timer.stop() longClicked() } else { //do nothing } } } onCanceled: { if(timerCount != 0) { if(true == timer.running) timer.stop() } } }