Skip to content

VisUI DragPane not working on gdx 1.9.6 #271

Open
@Honguito98

Description

@Honguito98
  • 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;
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions