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

go - serving up pdfs using golang -

how to add preprocess loader in webpack 2 -

python - django admin: changing the way a field (w/ relationship to another model) is submitted on a form so that it can be submitted multiple times -