Skip to content

Commit ea04bc5

Browse files
fix: constrain rubberband selection in display editor to stay within parent window
1 parent fd34be2 commit ea04bc5

File tree

1 file changed

+13
-0
lines changed
  • app/display/editor/src/main/java/org/csstudio/display/builder/editor/util

1 file changed

+13
-0
lines changed

app/display/editor/src/main/java/org/csstudio/display/builder/editor/util/Rubberband.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,22 @@ private void handleDrag(final MouseEvent event)
8383
{
8484
if (! active)
8585
return;
86+
87+
// Get the current coords of the pointer, relative to the parent
8688
final Point2D in_parent = parent.sceneToLocal(event.getSceneX(), event.getSceneY());
8789
x1 = in_parent.getX();
8890
y1 = in_parent.getY();
91+
92+
// If outside the parent window,
93+
// then set the coords to the parent window border (zero)
94+
if(x1 <-1) {
95+
x1 = 0;
96+
}
97+
if(y1 <-1) {
98+
y1 = 0;
99+
}
100+
101+
// Update the rectangle coords and dimensions
89102
rect.setX(Math.min(x0, x1));
90103
rect.setY(Math.min(y0, y1));
91104
rect.setWidth(Math.abs(x1 - x0));

0 commit comments

Comments
 (0)