From 361d2932f6b701dda14a449e5e2439e93d08f0a4 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:46:29 +0800 Subject: [PATCH] add mouse wheel scrolling for channel data Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../gui/GuiScreenConfigureChannels.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gtnewhorizon/structurelib/gui/GuiScreenConfigureChannels.java b/src/main/java/com/gtnewhorizon/structurelib/gui/GuiScreenConfigureChannels.java index da7dfa6c..ac4782e9 100644 --- a/src/main/java/com/gtnewhorizon/structurelib/gui/GuiScreenConfigureChannels.java +++ b/src/main/java/com/gtnewhorizon/structurelib/gui/GuiScreenConfigureChannels.java @@ -222,10 +222,27 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen return buttonList; } + private boolean isMouseOverValue() { + int mx = Mouse.getEventX() * this.width / this.mc.displayWidth; + int my = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + return mx >= value.xPosition && mx < value.xPosition + value.width && my >= value.yPosition && my < value.yPosition + value.height; + + } + @Override public void handleMouseInput() { int delta = Mouse.getEventDWheel(); - if (delta != 0) list.handleDWheel(delta); + if (delta != 0) { + if (isMouseOverValue()) { + if (delta > 0) { + value.setText(String.valueOf(getValue() + 1)); + } else { + value.setText(String.valueOf(Math.max(getValue() - 1, 1))); + } + } else { + list.handleDWheel(delta); + } + } super.handleMouseInput(); }