09-20-2012 08:58 AM
Hi
Does anybody know if the time between screen taps that constitues a double-tap can be modified in a Qt application? Ideally, without modifying Qt itself
Actually, modifying Qt isn't really a problem, since each application needs its own copy of the Qt libraries anyway. I just couldn't find where in the Qt code this was done. I'm not even sure whether Qt receives a specific double-tap event from the native event loop, or if it works out its own double-taps from the times between single-taps.
Best wishes
Kevin
09-21-2012 03:38 PM
09-24-2012 04:33 AM
Thanks, but it didn't seem to make much difference for me. Does this method work for you?
To be honest, I have a suspicion that it's not the interval that makes the application seem insensitive to double-clicks, but how close together the screen taps have to be. I'm not sure what can be done about that.
09-24-2012 06:42 AM
If thats the issue, try this. It woks for QML Listviews, Buttons, etc. Not sure it works for double-tap as well, though.
QApplication app(argc, argv); // Because of the hi-res BB10 display be need a higher tolerance to mouse movements app.setStartDragDistance(16);
09-24-2012 09:07 AM
Hi
Thanks. This does seem to help a bit.
Best wishes
Kevin
09-25-2012 05:31 PM - edited 09-25-2012 05:34 PM
I have the same problem, but using QApplication::setStartDragDistance() with high values isn't a good solution because it poors usability of Flickable-based components. So, I've done double tap handling on my own. Here's the code snippet, maybe you find it useful:
import QtQuick 1.1
Item {
id: container
signal clicked
signal doubleClicked
MouseArea {
property double __clickTime: 0
property int __mouseX: 0
property int __mouseY: 0
// Tune double tap here
property int __doubleClickInterval: 400 // ms
property int __doubleClickDistance: 100 // px
Timer {
id: clickTimer
interval: __doubleClickInterval
onTriggered: {
container.clicked()
parent.__clickTime = 0
}
}
onClicked: {
// Handle single/double click on our own
if (__clickTime === 0) {
__clickTime = Date.now()
clickTimer.start()
__mouseX = mouse.x
__mouseY = mouse.y
} else if (Date.now() - __clickTime < __doubleClickInterval) {
clickTimer.stop()
__clickTime = 0
if (Math.sqrt(Math.pow(__mouseX - mouse.x, 2) +
Math.pow(__mouseY - mouse.y, 2)) < __doubleClickDistance) {
container.doubleClicked()
}
}
}
anchors.fill: parent
}
}