I have a draggable image in Drag Target, I can move it around but it is not accepted in another Drag Target, I am sure Drag Target returns true every time for willAccept(). How to handle this?
Issue: How to drag object from one DragTarget to other?
Resolved!
The drag target now returns Draggable
Related
Imagine a scenario where I have a large draggable and two small drag targets. I want to register a drop on both smaller drag targets when the draggable widget is dropped on top of both; similarly a drop on one drag target if the draggable only covers one etc...
Can this be acheived with draggables, or any other method?
Context of flutter draggables like this demo.
The described behaviour is that event happens when you drag and drop the draggable into the drag target. But actually it's only registered if your cursor/finger is within the drag target's widget bounds when you drop. A drop isn't registered if the draggable widget is dropped on top of the drag target unless your pointer is within the bounds of the drag target.
By default in the picture above, the green box(drag target) is empty. When the red box(A) is dragged is stays in the green box and then this red box (now inside the green, also acts as a drag target). So that now the black box(B) can be dropped into it. How do I do this in flutter With Draggable and Drag target. Thanks in advance.
I think you need to use gesturedetector(tabdowndetails) to detect "x,y" while moving users finger across the screen. You can paint target rectangle(const dimensions) dynamically following users finger.
btw. where do you plan to drag the boxes(objects, picts)?
I have an Android application with some draggable elements.
There are some some labels that I want do drag over containers. The moment I drag over the container, I want the container background to change its colour.
I am unable to achieve this with DragOverListener from the API.
This is my code:
label.addDragOverListener(l -> {
container.getAllStyles().setBgColor(ColorUtil.YELLOW);
container.getAllStyles().setBgTransparency(255);
});
What happens is that as soon as I start dragging the label, the container changes the colour. But that's not what I want. I want the container to change the colour only when I drag over it.
Is there a way to achieve this?
Many thanks in advance.
The event delivers an X/Y location for the drag which you can use to determine whether to draw the color or not. Generally, this API is designed for refined drawing of this type e.g. drawing a square in the place the dropped component will occupy.
I want my Drag target to follow the draggable widget when it moves, really appreciate if you could help!
Before Drag
After Drag
Im making an iPad app that will have some objects on the screen in a menu area. I want the user to be able to touch down and drag from one of these objects to place a new copy of that object on the view.
To further explain, say I have a checkers chip on the side of the UIView in the "game piece" / menu area. I want the user to touch down and drag from that checkers piece to drag a new checker piece onto the game board. I dont want the original checker to move, its just a place holder, but I want to create a new object that is dragged from the first checker.
I see a couple of ways to do that however I cant figure out how to do it without the user picking up their finger to reselect the new game piece. I want the new piece to be drag able immediately after touching the first place holder object.
Any ideas? Please and thank you for the assistance.
I've solved this before by creating a copy of the UIView that I wish to move, then using the UIResponder API (touchesBegan, etc.) to move the new copy in its superview based on the drag gesture translation, thereby leaving the original "menu" view in situ. Does this make sense?
When you create the moveable copy, you can set its alpha or create a border or some other visual confection to indicate the provisional nature of the drag object.