I have a Qt QML 6.5 flickable that I would like to drag the contents of using the right mouse button. Following this question, I implemented a custom DragHandler QML: acceptedButtons for Flickable with example code shown below. When I use the default handler, it uses less mouse button to drag but is free flowing so when you flick the contents, it keeps scrolling, and when I drag past the start or end of content it "bounces back". With a custom DragHandler, all that extra behavior goes away. Is there a way to use Right Mouse button AND keep this cool responsive/interactive behavior?
Flickable
{
id: mainFlick
anchors.fill: parent
contentWidth: mainTimeBarsContent.width; contentHeight: height
onContentXChanged: { if(flicking) hbar.setPosition(contentX/contentWidth)}
clip:true
interactive:false
DragHandler {
property real _startX
property real _startY
acceptedButtons: Qt.RightButton
dragThreshold: 0
target: null
yAxis.enabled : false
onActiveChanged: {
if (active) {
_startX = mainFlick.contentX
//_startY = mainFlick.contentY
}
}
onTranslationChanged: {
mainFlick.contentX = _startX - translation.x
//mainFlick.contentY = _startY - translation.y
}
}
Rectangle { id:contentStuff
width:5000
color:"red"
}
}