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

android - IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

c# - Oracle Advanced Queues - Dequeueing Commit/Rollback -