refactor(renderer): improve mouse event handling in ScrollArea and CustomWindowPanel

This commit is contained in:
extio-de
2026-01-26 21:41:50 +01:00
parent eae2e30684
commit 16208971aa
3 changed files with 7 additions and 2 deletions

View File

@@ -83,6 +83,10 @@ public class ScrollArea implements WindowComponent {
protected void onMouseWheelEvent(final MouseClickEvent event) { protected void onMouseWheelEvent(final MouseClickEvent event) {
if (event.getButton() == 4 || event.getButton() == 5) { if (event.getButton() == 4 || event.getButton() == 5) {
if (Window.getContainerUnderCursor(event) != this.parent) {
return;
}
if (!SpatialUtils2.intersects( if (!SpatialUtils2.intersects(
this.relativeArea.getPosition().add(this.parent.getAbsolutePosition()), this.relativeArea.getPosition().add(this.parent.getAbsolutePosition()),
this.relativeArea.getDimension(), this.relativeArea.getDimension(),

View File

@@ -213,7 +213,7 @@ public class Window extends AbstractClientModule implements InitializingBean {
} }
protected void onMouseClickEvent(final MouseClickEvent event) { protected void onMouseClickEvent(final MouseClickEvent event) {
final Window containerUnderCursor = this.getContainerUnderCursor(event); final Window containerUnderCursor = getContainerUnderCursor(event);
if (containerUnderCursor == this) { if (containerUnderCursor == this) {
if (event.isPressed() && !this.dragging) { if (event.isPressed() && !this.dragging) {
this.zIndexToTop(); this.zIndexToTop();
@@ -355,7 +355,7 @@ public class Window extends AbstractClientModule implements InitializingBean {
return this.normalizedArea.getDimension().toImmutableCoordI2(); return this.normalizedArea.getDimension().toImmutableCoordI2();
} }
private Window getContainerUnderCursor(final MouseEvent event) { public static Window getContainerUnderCursor(final MouseEvent event) {
Window containerUnderCursor = null; Window containerUnderCursor = null;
synchronized (DISPLAYED_CONTAINERS) { synchronized (DISPLAYED_CONTAINERS) {
short zIndexHighest = -1; short zIndexHighest = -1;

View File

@@ -92,6 +92,7 @@ public class CustomWindowPanel extends Component {
public void mouseWheelMoved(final MouseWheelEvent e) { public void mouseWheelMoved(final MouseWheelEvent e) {
if (CustomWindowPanel.this.getParent() instanceof final G2DMainFrame mainFrame) { if (CustomWindowPanel.this.getParent() instanceof final G2DMainFrame mainFrame) {
mainFrame.handleWheelMoved(e, ImmutableCoordI2.create(CustomWindowPanel.this.getX(), CustomWindowPanel.this.getY())); mainFrame.handleWheelMoved(e, ImmutableCoordI2.create(CustomWindowPanel.this.getX(), CustomWindowPanel.this.getY()));
e.consume();
} }
} }
}); });