0

I have a problem with a ScrollPane. I want to disable the panning. For the mouse it's very easy because of the setPannable(boolean) function. But that doesn't disable the panning for touch events. So is there a way to disable panning for touch events in a ScrollPane?

Thanks for your help.

2 Answers2

1

I now have a working solution. In the control you do not want to have scrolling of the scrollpane during DRAG operations add following filter.

// Filter all SCROLL Events, otherwise the parent scroll pane will pan, 
// somehow is this workaround 

button2.addEventFilter(InputEvent.ANY, (event)-> {
    if (event.getEventType().toString() == "SCROLL")
        event.consume();
});

button2 is a simple ToggleButton. Should work with any other control.

ByteHamster
  • 4,884
  • 9
  • 38
  • 53
0

Have you tried to implement the setOnTouch...() methods associated with touch events for your ScrollPane ? If you consume the event then touch gestures will have no effects.

Example :

    ScrollPane sp = new ScrollPane();
    sp.addEventHandler(TouchEvent.ANY, new EventHandler<TouchEvent>() {
        @Override
        public void handle(TouchEvent event) {
            event.consume();                
        }
    });

Hope I helped you

Marc
  • 2,631
  • 1
  • 12
  • 13