diff options
Diffstat (limited to 'src/client/java')
3 files changed, 20 insertions, 1 deletions
diff --git a/src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java b/src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java index e28509e..07f5635 100644 --- a/src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java +++ b/src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java @@ -3,6 +3,7 @@ package dev.isxander.yacl.gui; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.ContainerObjectSelectionList; +import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.util.Mth; import org.jetbrains.annotations.Nullable; @@ -92,6 +93,17 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten return null; } + @Override + public boolean mouseReleased(double mouseX, double mouseY, int button) { + // on mouseClicked, the clicked element becomes focused so you can drag. on release, we should clear the focus + boolean clicked = super.mouseReleased(mouseX, mouseY, button); + if (getFocused() != null) { + this.getFocused().setFocused(null); + this.setFocused(null); + } + return clicked; + } + /* below code is licensed from cloth-config under LGPL3 modified to inherit vanilla's EntryListWidget and use yarn mappings diff --git a/src/client/java/dev/isxander/yacl/gui/OptionListWidget.java b/src/client/java/dev/isxander/yacl/gui/OptionListWidget.java index 097f076..333d67c 100644 --- a/src/client/java/dev/isxander/yacl/gui/OptionListWidget.java +++ b/src/client/java/dev/isxander/yacl/gui/OptionListWidget.java @@ -150,6 +150,13 @@ public class OptionListWidget extends ElementListWidgetExt<OptionListWidget.Entr } @Override + public void mouseMoved(double mouseX, double mouseY) { + if (getFocused() instanceof OptionEntry optionEntry) + optionEntry.widget.unfocus(); + setFocused(null); + } + + @Override public boolean mouseScrolled(double mouseX, double mouseY, double amount) { super.mouseScrolled(mouseX, mouseY, amount); diff --git a/src/client/java/dev/isxander/yacl/gui/controllers/BooleanController.java b/src/client/java/dev/isxander/yacl/gui/controllers/BooleanController.java index d97b418..d7d17d5 100644 --- a/src/client/java/dev/isxander/yacl/gui/controllers/BooleanController.java +++ b/src/client/java/dev/isxander/yacl/gui/controllers/BooleanController.java @@ -142,7 +142,7 @@ public class BooleanController implements Controller<Boolean> { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - if (!focused) { + if (!isFocused()) { return false; } |