Skip to content

Commit

Permalink
fix: Unrestrict mouse events from propagating between option components
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o committed Jan 4, 2025
1 parent b6b9373 commit e594eec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,10 @@ public boolean mouseInput(int mouseX, int mouseY, MouseEvent mouseEvent) {
if (editor == null) {
continue;
}
editor.setGuiContext(guiContext);
ContextAware.wrapErrorWithContext(editor, () -> {
editor.setGuiContext(guiContext);
return null;
});
if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
if (accordion.getToggled()) {
Expand Down Expand Up @@ -970,8 +973,8 @@ public boolean mouseInput(int mouseX, int mouseY, MouseEvent mouseEvent) {
}
}

if (mouseX > innerLeft && mouseX < innerRight &&
mouseY > innerTop && mouseY < innerBottom) {
boolean handled = false;
{
optionY = -optionsScroll.getValue();
if (getSelectedCategory() != null && getCurrentlyVisibleCategories() != null &&
getCurrentlyVisibleCategories().containsKey(getSelectedCategory())) {
Expand Down Expand Up @@ -1014,14 +1017,14 @@ public boolean mouseInput(int mouseX, int mouseY, MouseEvent mouseEvent) {
mouseY,
mouseEvent
))) {
return true;
handled = true;
}
optionY += ContextAware.wrapErrorWithContext(editor, editor::getHeight) + 5;
}
}
}

return true;
return handled;
}

public boolean keyboardInput(KeyboardEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class ContextAware {

public static <T> T wrapErrorWithContext(Field field, ContextAwareRunnable<T> runnable) {
return wrapErrorWithContext(field::toString, runnable);
return wrapErrorWithContext(field != null ? field::toString : null, runnable);
}

public static <T> T wrapErrorWithContext(HasDebugLocation debugLocation, ContextAwareRunnable<T> runnable) {
Expand Down

0 comments on commit e594eec

Please sign in to comment.