aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java
diff options
context:
space:
mode:
authorxander <xander@isxander.dev>2022-09-02 22:04:35 +0100
committerxander <xander@isxander.dev>2022-09-02 22:04:35 +0100
commit7f88ddf36ba7804211e8aae6b3723bd8f37c82c5 (patch)
tree791e5cb050aa1ea17bd86d0bdd64fa441b2ab123 /src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java
parentdd24e4f8e84ed02913196c8ad6093275acc92219 (diff)
downloadYetAnotherConfigLib-7f88ddf36ba7804211e8aae6b3723bd8f37c82c5.tar.gz
YetAnotherConfigLib-7f88ddf36ba7804211e8aae6b3723bd8f37c82c5.tar.bz2
YetAnotherConfigLib-7f88ddf36ba7804211e8aae6b3723bd8f37c82c5.zip
implement keyboard-operation for all controllers
fix crash when focusing on option list with tab add tooltip to groups check that pending values actually applied on save, if not, error in log and the save button displays an error when trying to escape with unsaved changes, save button text goes green and bold YACLConstants file to change certain behaviours, could evolve into its own settings! update icon
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java')
-rw-r--r--src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java b/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java
index 92ef3d5..d198c96 100644
--- a/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java
+++ b/src/main/java/dev/isxander/yacl/gui/controllers/ActionController.java
@@ -6,6 +6,7 @@ import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.YACLScreen;
import net.minecraft.text.Text;
import org.jetbrains.annotations.ApiStatus;
+import org.lwjgl.glfw.GLFW;
import java.util.function.Consumer;
@@ -71,17 +72,32 @@ public class ActionController implements Controller<Consumer<YACLScreen>> {
super(control, screen, dim);
}
+ public void executeAction() {
+ playDownSound();
+ control.option().action().accept(screen);
+ }
+
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (isMouseOver(mouseX, mouseY)) {
- playDownSound();
- control.option().action().accept(screen);
+ executeAction();
return true;
}
return false;
}
@Override
+ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
+ if (keyCode != GLFW.GLFW_KEY_ENTER && keyCode != GLFW.GLFW_KEY_SPACE && keyCode != GLFW.GLFW_KEY_KP_ENTER) {
+ return false;
+ }
+
+ executeAction();
+
+ return true;
+ }
+
+ @Override
protected int getHoveredControlWidth() {
return getUnhoveredControlWidth();
}