java - Javafx limiting drag within window -


i making app has draggable background, work correctly, can drag, have noticed that, can drag past window , scene re-structure , allow me drag far want in given direction, here snippet show mean normal before dragging after dragging far bottom right noticed scene has allowed imageview go far mouse takes it, how can limit stay within window? here code

 this.imgadvertising.setonmousepressed(e -> {        dragdelta.x = this.imgadvertising.getlayoutx() - e.getscenex();       dragdelta.y = this.imgadvertising.getlayouty() - e.getsceney();  });   this.imgadvertising.setonmousedragged(e -> {      double x = e.getscenex() + dragdelta.x;     double y = e.getsceney() + dragdelta.y;     this.imgadvertising.setlayoutx(e.getscenex() + dragdelta.x);     this.imgadvertising.setlayouty(e.getsceney() + dragdelta.y); }); 


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -