Open
Description
- VisUI version: 1.30
- Gdx version: 1.9.6
- Issue: dragging children will not change their position
- Posible solution: from gdx 1.9.*
addActor*()
methods will do nothing when child is already on the group. So we need to remove the actor before calling these methods. - Code snippet:
protected boolean addToHorizontalGroup (final Actor actor, final DragPane dragPane, final Actor directPaneChild) {
final Array<Actor> children = dragPane.getChildren();
final int indexOfDraggedActor = children.indexOf(actor, true);
final int indexOfDirectChild = children.indexOf(directPaneChild, true);
actor.remove(); // gdx 1.9.6 addActor*() expects children are not added in the group before
if (indexOfDraggedActor >= 0) {
if (indexOfDirectChild > indexOfDraggedActor) {
dragPane.addActorAfter(directPaneChild, actor);
} else {
dragPane.addActorBefore(directPaneChild, actor);
}
} else if (DRAG_POSITION.x > directPaneChild.getWidth() / 2f) {
dragPane.addActorAfter(directPaneChild, actor);
} else {
dragPane.addActorBefore(directPaneChild, actor);
}
return APPROVE;
}