From 9dce73ba8c10960e6502825b14c91e6ec56393a4 Mon Sep 17 00:00:00 2001 From: isXander Date: Thu, 29 Feb 2024 22:24:57 +0000 Subject: Fix keyboard/controller navigation not properly scrolling when overflowing --- .../java/dev/isxander/yacl3/gui/ElementListWidgetExt.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'common/src/main/java') diff --git a/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java b/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java index 91cda1f..3ae9bdb 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java @@ -123,6 +123,20 @@ public class ElementListWidgetExt> exten return integer; } + @Override + protected void ensureVisible(E entry) { + int i = this.getRowTop(this.children().indexOf(entry)); + int j = i - this.getY() - 4 - entry.getItemHeight(); + if (j < 0) { + this.setScrollAmount(this.getScrollAmount() + j); + } + + int k = this.getBottom() - i - entry.getItemHeight() * 2; + if (k < 0) { + this.setScrollAmount(this.getScrollAmount() - k); + } + } + @Override protected void renderList(GuiGraphics graphics, int mouseX, int mouseY, float delta) { int left = this.getRowLeft(); -- cgit