2

I have made a horizontal pagedScrollPane according to tutorial here. Every page consists of the table with normal vertical ScrollPane.

I need to scroll vertically if initial drag was vertical and scroll between pages if drag was horizontal. I realised that I had to do myScroll.setCancelTouchFocus(false); with both scrollPanes to be able to activate the vertical scrollPane. Then I decided to setCancelTouchFocus to true if I want a scrollPane to disable.

scrollVert.addListener(new DragListener() {

    @Override
    public void drag(InputEvent event, float x, float y, int pointer) {
        if (!scrolling) {
            float dX = Math.abs(getDeltaX());
            float dY = Math.abs(getDeltaY());
            if (dX != 0 || dY != 0) {
                if (dX > dY) {
                    scrollPages.setCancelTouchFocus(true);
                } else {
                    scrollVert.setCancelTouchFocus(true);
                }
            scrolling = true;
            }
        }
        super.drag(event, x, y, pointer);
    }

    @Override
    public void touchUp(InputEvent event, float x, float y, int pointer, int button) {              
        scrolling = false;
        scrollPages.setCancelTouchFocus(false);
        scrollVert.setCancelTouchFocus(false);              
        super.touchUp(event, x, y, pointer, button);
    }
});

The problem is that if I drag diagonally (or fast right and down) the scrollPane jumps a little bit sideways and only then decides where to scroll.

dStulle
  • 609
  • 5
  • 24
E. Kross
  • 135
  • 1
  • 11
  • This is a hard one since either of the scroll able actors will take control of the dragging. There was a recent question about something similar, you might get going from there: http://stackoverflow.com/questions/35487020/how-to-scroll-a-scrollpane-in-code/35528949#comment58772721_35528949 – Madmenyo Mar 01 '16 at 17:32

0 Answers0