Using Flickable signals to remove hover state instead of timer. No more delays

This commit is contained in:
vladest 2017-12-02 13:57:12 +01:00
parent 570be69fcf
commit fd9539a9e4
2 changed files with 14 additions and 9 deletions

View file

@ -13,9 +13,6 @@ Item {
property int columnIndex: 1 // point to 'go to location' property int columnIndex: 1 // point to 'go to location'
property int count: 0 property int count: 0
//timeout for press delay before swipe occurs
readonly property int pressDelayTime: HMD.active ? 150 : 100
// used to look up a button by its uuid // used to look up a button by its uuid
function findButtonIndex(uuid) { function findButtonIndex(uuid) {
if (!uuid) { if (!uuid) {
@ -67,6 +64,7 @@ Item {
} else { } else {
button.tabletRoot = parent.parent; button.tabletRoot = parent.parent;
} }
button.flickable = swipeView.contentItem
sortButtons(gridIndex); sortButtons(gridIndex);
@ -217,11 +215,6 @@ Item {
top: parent.top top: parent.top
bottom: pageIndicator.top bottom: pageIndicator.top
} }
Component.onCompleted: {
if (contentItem !== null) {
contentItem.pressDelay = tablet.pressDelayTime
}
}
} }
PageIndicator { PageIndicator {

View file

@ -23,11 +23,22 @@ Item {
property double sortOrder: 100 property double sortOrder: 100
property int stableOrder: 0 property int stableOrder: 0
property var tabletRoot; property var tabletRoot;
property var flickable: null
width: 129 width: 129
height: 129 height: 129
signal clicked() signal clicked()
Connections {
target: flickable
onMovingChanged: {
//when flick/move started, and hover is on, clean hove state
if (flickable.moving && tabletButton.state.indexOf("hover") !== -1) {
tabletButton.state = (tabletButton.isActive) ? "active state" : "base state";
}
}
}
function changeProperty(key, value) { function changeProperty(key, value) {
tabletButton[key] = value; tabletButton[key] = value;
} }
@ -121,7 +132,7 @@ Item {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
enabled: true enabled: true
preventStealing: true preventStealing: false
onClicked: { onClicked: {
console.log("Tablet Button Clicked!"); console.log("Tablet Button Clicked!");
if (tabletButton.inDebugMode) { if (tabletButton.inDebugMode) {
@ -136,6 +147,7 @@ Item {
tabletInterface.playSound(TabletEnums.ButtonClick); tabletInterface.playSound(TabletEnums.ButtonClick);
} }
} }
onEntered: { onEntered: {
tabletButton.isEntered = true; tabletButton.isEntered = true;
tabletInterface.playSound(TabletEnums.ButtonHover); tabletInterface.playSound(TabletEnums.ButtonHover);