JavaFX: How to make a ScrollPane pan only on middle button? -
javafx's scrollpane panes on mouse events when allowed pan:
scrollpane.setpannable(true);
how limit scrollpane pan on middle mouse events, while still allowing events stackpane's content?
you should consume events except middle button events inside content's event handler:
// let scrollpane.viewrect pan on middle button. imagelayer.addeventhandler(mouseevent.any, event -> { if(event.getbutton() != mousebutton.middle) event.consume(); });
this works because scrollpane pans via event handler too, , event handlers invoked bottom-up. if consume event via child, won't scrollpane viewrect panning.
Comments
Post a Comment