From 37c278d4b1786b0584d47d2f7cc1fca460047feb Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Mon, 3 Aug 2020 01:37:13 +0300 Subject: Enable keyboard repeat events for LibGui screens Closes #27. --- .../github/cottonmc/cotton/gui/client/CottonClientScreen.java | 8 +++++++- .../cottonmc/cotton/gui/client/CottonInventoryScreen.java | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java index b3f9bcd..6adf34e 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonClientScreen.java @@ -49,13 +49,19 @@ public class CottonClientScreen extends Screen implements TextHoverRendererScree @Override public void init(MinecraftClient client, int screenWidth, int screenHeight) { - super.init(client, screenWidth, screenHeight); + client.keyboard.enableRepeatEvents(true); description.addPainters(); reposition(screenWidth, screenHeight); } + @Override + public void removed() { + super.removed(); + this.client.keyboard.enableRepeatEvents(false); + } + /** * Repositions the root panel. * diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java index 6b65f07..e69755d 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java @@ -61,14 +61,21 @@ public class CottonInventoryScreen extends Handl */ @Override - public void init(MinecraftClient minecraftClient_1, int screenWidth, int screenHeight) { - super.init(minecraftClient_1, screenWidth, screenHeight); + public void init(MinecraftClient client, int screenWidth, int screenHeight) { + super.init(client, screenWidth, screenHeight); + client.keyboard.enableRepeatEvents(true); description.addPainters(); reposition(screenWidth, screenHeight); } + @Override + public void removed() { + super.removed(); + this.client.keyboard.enableRepeatEvents(false); + } + /** * Clears the heavyweight peers of this screen's GUI description. */ -- cgit