Get SwipeView gesture
Unsolved
Mobile and Embedded
-
Hello,
I have the following problem. I have 3 pages in a swipeView and I want to catch a swipe Gesture when I am on the first page (and when I make a swipe to go to page -1 - which doesn't exists ) and to interpret this gesture and do something else with (like opening a left menu on mobile)
I did't know how to extract it from a swipeView, so I basically put a MauseArea like this:
MouseArea { id: temporary_swipe_ anchors.fill: parent property point origin property bool ready: false signal move(int x, int y) signal swipe(string direction) propagateComposedEvents: true onMove: { console.log("******************I just moved x= ", x, " y=",y) } onSwipe: { console.log("******************I just swiped= ", direction) } onPressed: { console.log("**********************am intrat pe aici: onPressed") drag.axis = Drag.XAndYAxis origin = Qt.point(mouse.x, mouse.y) mouse.accepted = false; } onPositionChanged: { console.log("**********************am intrat pe aici: Position CHanged") switch (drag.axis) { case Drag.XAndYAxis: if (Math.abs(mouse.x - origin.x) > 16) { drag.axis = Drag.XAxis } else if (Math.abs(mouse.y - origin.y) > 16) { drag.axis = Drag.YAxis } break case Drag.XAxis: move(mouse.x - origin.x, 0) break case Drag.YAxis: move(0, mouse.y - origin.y) break } //mouse.accepted = false; } onReleased: { console.log("**********************am intrat pe aici: onReleased") switch (drag.axis) { case Drag.XAndYAxis: canceled(mouse) break case Drag.XAxis: swipe(mouse.x - origin.x < 0 ? "left" : "right") break case Drag.YAxis: swipe(mouse.y - origin.y < 0 ? "up" : "down") break } mouse.accepted = false; } }
I used mouse.accepted to pass the event lower, but the problem is: if onPressed gets "mouse.accepted = false;", then the onReleased and onPositionChanged never gets triggered.
Otherwise, if onPressed gets consumend, I can't do the regular stuff in my original SwipeView.
Has anyone tried to achieve something similar?
With best regards.
Flavian