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.