A way to handle multiple finger events on phones ?

Started by Nafffen, 22 February 2024, 17:57:27

Nafffen

Hey, I am trying to have a SFML Canvas in which I can navigate with 1 or 2 fingers.
I want to zoom in the view by pinching 2 fingers, but I need to keep track of each finger down and their position.
I know touch events are translated to mouse events for most cases. So I can't handle zooming with the information leftMousePressed is giving me.
Is there a trick to have a better fingers handle, or can I just cancel all tgui events for this widget and transmit SFML's ones ?
thank you

texus

You will need the touch events that you get directly from SFML in your main loop for this.

I could maybe add a new event, something like a PinchZoom event, which works similarly to mouse wheel scrolling (i.e. has one + or - parameter with a relative value since the last position). I'm however uncertain how to properly detect a pinch zoom, and I'm not sure what the value should even be. As soon as you put 2 fingers down, TGUI will currently already think that you are scrolling with two fingers (which is an assumption I could only make because no other gestures were supported). So adding the event (which I'd be willing to do), is the least amount of work. Getting both zooming and scrolling with two fingers to behave well would be a lot harder (and not something that I'm currently willing to do).