Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisUI DragPane not working on gdx 1.9.6 #271

Open
Honguito98 opened this issue Oct 10, 2017 · 3 comments
Open

VisUI DragPane not working on gdx 1.9.6 #271

Honguito98 opened this issue Oct 10, 2017 · 3 comments
Labels

Comments

@Honguito98
Copy link

  • 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;
	}
@kotcrab kotcrab added the ui label Oct 11, 2017
@kotcrab
Copy link
Owner

kotcrab commented Oct 11, 2017

@czyzby can you take a look at this?

@czyzby
Copy link
Collaborator

czyzby commented Oct 11, 2017

Looks like @Honguito98 already figured out the issue - @Honguito98, would you mind creating a pull request with your changes? Keep in mind that this approach should be applied to other group handling methods.

@kotcrab
Copy link
Owner

kotcrab commented Dec 20, 2017

Well I added it but the behavior with tabbed pane seems different than before. Most of the time actor gets added one actor after the actor it was dropped on. But only when dragging from left to right. Dragging from right to left seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants