DragListener gets Interrupted

Anything libgdx related goes here!

DragListener gets Interrupted

Postby twinflyer » Wed Sep 17, 2014 2:40 pm

Hello everybody,
I tried implementing a DragListener to drag some Tables around but for some reason the drag events stop during dragging. "dragStop" and "touchUp" are called when the drag moves to far away from the point where dragging was started ("to far" means something like 5mm/0.2 inches).

This is the code I'm using for testing purposes:
Code: Select all
         listItemTop.addListener(new EventListener() {
            
            @Override
            public boolean handle(Event event) {
               if (event instanceof InputEvent) {
                  System.out.println("EventListener: "+((InputEvent) event).getType());
               }
               return false;
            }
         });
         DragListener listener = new DragListener() {
            
            public void dragStart (InputEvent event, float x, float y, int pointer) {
               System.out.println("Draglistener: dragStart");
            }

            public void drag (InputEvent event, float x, float y, int pointer) {
               System.out.println("Draglistener: drag");
            }

            public void dragStop (InputEvent event, float x, float y, int pointer) {
               System.out.println("Draglistener: dragStop");
            }
            
            @Override
            public boolean handle(Event e) {
               System.out.println("Draglistener: " + e);
               return super.handle(e);
            }
            
         };


And this is the output I get (with a few comments):
Code: Select all
// ....
Draglistener: mouseMoved
EventListener: touchDown         //touchdown
Draglistener: touchDown
EventListener: enter
Draglistener: enter
Draglistener: touchDragged        // start dragging
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: touchDragged
Draglistener: dragStart
Draglistener: drag
Draglistener: touchDragged
Draglistener: drag
Draglistener: touchDragged
Draglistener: drag
Draglistener: touchDragged
Draglistener: drag
Draglistener: touchDragged
Draglistener: drag
Draglistener: touchDragged
Draglistener: drag
Draglistener: touchUp                //still dragging, but no more output is given until i release mouse button
Draglistener: dragStop


I hope you can help me solving this annoying problem :x

Thanks,
twinflyer
twinflyer
 
Posts: 3
Joined: Wed Sep 17, 2014 2:29 pm

Re: DragListener gets Interrupted

Postby Phibedy » Wed Sep 17, 2014 8:14 pm

Some more information:
we are using 1.3.2-Snapshot,
In Overview.class we have the draglistener, I overwrite touchUp() in the draglistener (still call super.touchUp)
Code: Select all
java.lang.Exception
   at de.mineforce.missionsnap.gui.pages.Overview$4.touchUp(Overview.java:279)
   at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:57)
   at com.badlogic.gdx.scenes.scene2d.Stage.cancelTouchFocus(Stage.java:495)
   at com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.cancelTouchFocusedChild(ScrollPane.java:236)
   at com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$2.pan(ScrollPane.java:188) //***
   at com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener$1.pan(ActorGestureListener.java:67)
   at com.badlogic.gdx.input.GestureDetector.touchDragged(GestureDetector.java:161)
   at com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener.handle(ActorGestureListener.java:111)
   at com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$2.handle(ScrollPane.java:205)
   at com.badlogic.gdx.scenes.scene2d.Stage.touchDragged(Stage.java:306)
   at com.badlogic.gdx.InputMultiplexer.touchDragged(InputMultiplexer.java:102)
   at com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents(LwjglInput.java:328)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:199)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)

//***That "calls" the touchUp-event as on "pan" the children loose their focus.

It seems to be the expected behavior but I dont get why it's done that way, as you cant have an draglistener inside a scrollpane.
Is it necessary that Scrollpane removes the drag-focus of its childs?
I am not sure as Scrollpane.class doesnt have to much comments in it and I cant test it as cancelTouchFocusedChild(...) is default :)
Cheers
Phibedy
 
Posts: 18
Joined: Thu Apr 04, 2013 7:40 pm

Re: DragListener gets Interrupted

Postby evilentity » Thu Sep 18, 2014 2:41 pm

Scrollpane is annoying like that. It wants all the focus it can get. You can stop it from doing that with additional listener. It should be on first or second page of this forum.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4867
Joined: Wed Aug 24, 2011 11:37 am

Re: DragListener gets Interrupted

Postby Phibedy » Thu Sep 18, 2014 7:59 pm

evilentity wrote:Scrollpane is annoying like that. It wants all the focus it can get. You can stop it from doing that with additional listener. It should be on first or second page of this forum.

I already read it, but all actors inside the scrollpane would need that listener. Actors can be draged to the left/right. Scrollpane only scrolls y. The best way would be to be able to overwrite the pan() method inside the flickerlistener (not sure how it's called). Maybe adding something like
Code: Select all
if(scrollX && deltaX > deltaY){
//remove focus from children
}else if(scrollY && deltaY > deltaX){
//remove focus from children
}

to Scrollpane would be usefull.
Phibedy
 
Posts: 18
Joined: Thu Apr 04, 2013 7:40 pm


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 1 guest