How to use Flutter's InteractiveViewer in a way that it doesn't hijack all the gesture input? - flutter

I'm creating some kind of image editor (kinda like Canva). For zooming in, out, and panning, I use InteractiveViewer. But the thing is, once I start using InteractiveViewer, I noticed that my other gestures for the elements inside the canvas (e.g. tap and drag on an element should drag the element around) are not working. Tapping and dragging now become panning the whole canvas.
This is still the case even if I turn off panning and scaling (panEnabled: false, scaleEnabled: false). Thankfully single tap is still working because InteractiveViewer does not use that, but I need the entire gesture input when the user makes input that's not intended for the InteractiveViewer. For example, if the user taps on an element so it becomes selected, then all the gesture input should go to the tapped element instead of to InteractiveViewer.
I once thought of a solution to just simply not using InteractiveViewer when there's an element selected, but that causes the user to immediately lose the zoom and pan previously set before. I need solution so that the InteractiveViewer can preserves the zoom and pan setting while letting all the gesture input goes through to the elements inside. How can I do that?

Related

How to disable map events for elements in the DOM?

The map has some default events, like when you use the scroll wheel on your mouse the map will zoom in and out.
I would like to know how to disable this behavior for certain elements in the DOM?
For example, using the mouse scroll wheel on top of the layers element. This does not trigger the map zoom event.
I want to replicate this behavior for a custom div element I have created. Currently when you hover the mouse on top of the element and use the mouse wheel it will zoom the map in and out.
The purpose of this is to allow for mouse scrolling on a div on top of the map which has an overflow scroll property on it.
I tried inspecting the layer element to see what is causing the map events to be disabled here.

Unity: How can I make a button clickable under an draggable area?

I am working on a screen of a game, and I want this behaviour: when you swipe in any place of the screen (even over a button) you can scroll, but at the same time you can click in any button.
Now I have a big empty image occupying the whole screen that can capture the drag events, but since raycast is ON, click events are not passing down to the elements below in the hierarchy. So buttons are not working.
Which is the proper way of achieving this?

Continuously scrolling UI Unity

So I am working working on something in unity (2d game). I have a list of button (UI) on my scene and I want to implement a scrolling mechanism. What is the best way to go about it? Currently , I can scroll through horizontally because I have added a "scroll rect" to the the canvas holding the buttons as I start the game. However when I try to scroll back (horizontally, it goes beyond the Buttons. Is there a way to make the scrolling continuous such that as I scroll, from the first UI element when I get to the last one and I keep scrolling, it continues with the first element. or what should I do. please let me Know If i should clarify.
In the Scroll rect you can set the movement type. I don't think the kind of "infinite scroll" you are asking for is available.
For your case, I think that the Use Elastic or Clamped mode to force the content to remain within the bounds of the Scroll Rect should do the work.
In the case of the infinite scroll specifically needed, you would need to ask for that explicitely and show your attempt for more specific help.

How to implement "hold and drag" gesture in flutter?

"hold and drag" - would be holding down with one finger and dragging horizontally (or vertically) with another.
GestureDetector would recognize it as Scale gesture. I want to differentiate between these 2:
Two fingers moving closer or further apart (normal scale)
One finger holding and another finger moving closer or further (I want to detect this)
There's a built-in Widget for that called LongPressDraggable you can use it similar to the Draggable widget.
The one main common difference being the ability to directly drag using the Draggable widget or hold and drag using the LongPressDraggable Widget.

Manage gestures priority between two widgets

I'm experimenting using the google maps for flutter plugin but I'm running into a problem managing the gesture priority.
My map, which need to handle gestures is rendered inside a PageView which also listen to some gestures. The thing is, It appears that the gesture handler of PageView take the priority over the map one, so if I drag vertically on the map, the map move but if I drag horizontally on the map, the page will switch instead of the map moving.
Is there a way to manage the priority between gesture handlers of widget to fix this sort of problems?