Skip to content

Commit e594eec

Browse files
committed
fix: Unrestrict mouse events from propagating between option components
1 parent b6b9373 commit e594eec

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

common/src/main/java/io/github/notenoughupdates/moulconfig/gui/MoulConfigEditor.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,10 @@ public boolean mouseInput(int mouseX, int mouseY, MouseEvent mouseEvent) {
858858
if (editor == null) {
859859
continue;
860860
}
861-
editor.setGuiContext(guiContext);
861+
ContextAware.wrapErrorWithContext(editor, () -> {
862+
editor.setGuiContext(guiContext);
863+
return null;
864+
});
862865
if (editor instanceof GuiOptionEditorAccordion) {
863866
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
864867
if (accordion.getToggled()) {
@@ -970,8 +973,8 @@ public boolean mouseInput(int mouseX, int mouseY, MouseEvent mouseEvent) {
970973
}
971974
}
972975

973-
if (mouseX > innerLeft && mouseX < innerRight &&
974-
mouseY > innerTop && mouseY < innerBottom) {
976+
boolean handled = false;
977+
{
975978
optionY = -optionsScroll.getValue();
976979
if (getSelectedCategory() != null && getCurrentlyVisibleCategories() != null &&
977980
getCurrentlyVisibleCategories().containsKey(getSelectedCategory())) {
@@ -1014,14 +1017,14 @@ public boolean mouseInput(int mouseX, int mouseY, MouseEvent mouseEvent) {
10141017
mouseY,
10151018
mouseEvent
10161019
))) {
1017-
return true;
1020+
handled = true;
10181021
}
10191022
optionY += ContextAware.wrapErrorWithContext(editor, editor::getHeight) + 5;
10201023
}
10211024
}
10221025
}
10231026

1024-
return true;
1027+
return handled;
10251028
}
10261029

10271030
public boolean keyboardInput(KeyboardEvent event) {

common/src/main/java/io/github/notenoughupdates/moulconfig/internal/ContextAware.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public class ContextAware {
1111

1212
public static <T> T wrapErrorWithContext(Field field, ContextAwareRunnable<T> runnable) {
13-
return wrapErrorWithContext(field::toString, runnable);
13+
return wrapErrorWithContext(field != null ? field::toString : null, runnable);
1414
}
1515

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

0 commit comments

Comments
 (0)