diff options
author | isXander <xandersmith2008@gmail.com> | 2023-03-29 17:11:24 +0100 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2023-03-29 17:11:24 +0100 |
commit | c5917e9854958adf1e4aa1aa22251f7b3f911d38 (patch) | |
tree | a6d9a9c37dc69e92ec8ce0bf9e03b2a0d3a502d8 | |
parent | c02229186aa13b1d699e2d00d24865260f158a54 (diff) | |
download | YetAnotherConfigLib-c5917e9854958adf1e4aa1aa22251f7b3f911d38.tar.gz YetAnotherConfigLib-c5917e9854958adf1e4aa1aa22251f7b3f911d38.tar.bz2 YetAnotherConfigLib-c5917e9854958adf1e4aa1aa22251f7b3f911d38.zip |
Fix buttons stuck focusing after clicking the mouse.
-rw-r--r-- | build.gradle.kts | 2 | ||||
-rw-r--r-- | changelogs/2.3.1.md | 1 | ||||
-rw-r--r-- | src/client/java/dev/isxander/yacl/gui/ElementListWidgetExt.java | 12 | ||||
-rw-r--r-- | src/client/java/dev/isxander/yacl/gui/OptionListWidget.java | 7 | ||||
-rw-r--r-- | src/client/java/dev/isxander/yacl/gui/controllers/BooleanController.java | 2 |
5 files changed, 22 insertions, 2 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 1d0d437..ac28484 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { val ciRun = System.getenv().containsKey("GITHUB_ACTIONS") group = "dev.isxander" -version = "2.3.0" +version = "2.3.1" if (ciRun) version = "$version+${grgit.branch.current().name.replace('/', '.')}-SNAPSHOT" diff --git a/changelogs/2.3.1.md b/changelogs/2.3.1.md new file mode 100644 index 0000000..13b4bd5 --- /dev/null +++ b/changelogs/2.3.1.md @@ -0,0 +1 @@ +- Fix buttons stuck focusing after clicking the mouse. 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; } |