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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -