Index: sources/gui/qml/components/TouchRect.qml =================================================================== diff -u -r4714af95cde20bc704971c6749a288a21979c24f -r27cb1be1e85e93cab858216f35c5d4d36a6ade5f --- sources/gui/qml/components/TouchRect.qml (.../TouchRect.qml) (revision 4714af95cde20bc704971c6749a288a21979c24f) +++ sources/gui/qml/components/TouchRect.qml (.../TouchRect.qml) (revision 27cb1be1e85e93cab858216f35c5d4d36a6ade5f) @@ -39,7 +39,7 @@ property bool selected : false property bool fading : false - + property int debouncingTime : 350 readonly property alias isPressed : _mouseArea.pressed property color textColor : Colors.textButton @@ -55,6 +55,12 @@ Colors.backgroundButtonSelectDark : Qt.darker (_root.backgroundColor, 1.15) + Timer { id: clickDeboundeTimer + interval: _root.debouncingTime // ms + } + Timer { id: pressDeboundeTimer + interval: _root.debouncingTime // ms + } QtObject { id: _private function color() { var mBackgroundColor = _root.backgroundColor @@ -78,6 +84,10 @@ } return _root.borderColor } + + property bool clickDeboucing: clickDeboundeTimer.running // if a click/press happens the timer starts, meaning we have to debounce. + property bool pressDeboucing: pressDeboundeTimer.running // if a click/press happens the timer starts, meaning we have to debounce. + property bool pressed : false // this will take care of releases happening during debounced press, therefor no release should happen as well. } color : _private.color() @@ -110,6 +120,11 @@ radius : Variables.touchRectRadius border.width: Variables.borderWidth + function onMouseEventLog(vMsg) { + // DEBUG: + console.log(vMsg, _text.text, Qt.formatTime(new Date(), "hh:mm:ss.zzz")) + } + Text { id: _text anchors.verticalCenter : parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter @@ -121,9 +136,9 @@ enabled : _root.touchable anchors.fill : parent anchors.margins : touchExpanding * -1 - onClicked : _root.clicked() - onPressed : _root.pressed() - onReleased : _root.released() - onPressAndHold : _root.pressAndHold() + onClicked : { if ( ! _private.clickDeboucing ) { onMouseEventLog("Clicked ") ; _root.clicked (); clickDeboundeTimer.start(); } } + onPressed : { if ( ! _private.pressDeboucing ) { onMouseEventLog("Pressed ") ; _private.pressed = true ; _root.pressed (); pressDeboundeTimer.start(); } } + onReleased : { if ( _private.pressed ) { onMouseEventLog("Released ") ; _private.pressed = false; _root.released (); pressDeboundeTimer.start(); } } + onPressAndHold : { onMouseEventLog("PressAndHold ") ; _root.pressAndHold(); } } }