diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java index 08a5dff00..24d08cff2 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java @@ -515,15 +515,28 @@ public abstract class GuiNPCInterface extends GuiScreen { } boolean subGui = hasSubGui(); + + // Mouse.getDWheel() clears the accumulated delta, so only the first caller in a frame + // ever sees it. Read it once here and let each widget take it in turn; anything that + // consumes it zeroes it so later widgets - the script editor, for one - are not left + // reading an already-drained wheel. + mouseScroll = Mouse.getDWheel(); + drawCenteredString(fontRendererObj, title, width / 2, guiTop + 4, 0xffffff); for (GuiNpcLabel label : labels.values()) label.drawLabel(this, fontRendererObj); for (GuiCustomScroll scroll : scrolls.values()) { scroll.updateSubGUI(subGui); - scroll.drawScreen(drawX, drawY, f, !subGui && scroll.isMouseOver(drawX, drawY) ? Mouse.getDWheel() : 0); + int delta = !subGui && scroll.isMouseOver(drawX, drawY) ? mouseScroll : 0; + if (delta != 0) + mouseScroll = 0; + scroll.drawScreen(drawX, drawY, f, delta); } for (GuiScrollWindow guiScrollableComponent : scrollWindows.values()) { - guiScrollableComponent.drawScreen(drawX, drawY, f, !subGui && guiScrollableComponent.isMouseOver(drawX, drawY) ? Mouse.getDWheel() : 0); + int delta = !subGui && guiScrollableComponent.isMouseOver(drawX, drawY) ? mouseScroll : 0; + if (delta != 0) + mouseScroll = 0; + guiScrollableComponent.drawScreen(drawX, drawY, f, delta); } for (GuiDiagram diagram : diagrams.values()) { diagram.drawDiagram(drawX, drawY, subGui); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java index 647621117..70283b7e0 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -624,9 +624,11 @@ public class GuiScriptTextArea extends GuiNpcTextField { int maxScroll = Math.max(0, getPaddedLineCount() - container.visibleLines); // Handle mouse wheel scroll - int wheelDelta = ((GuiNPCInterface) listener).mouseScroll = Mouse.getDWheel(); + // Take whatever the parent screen has left for this frame rather than polling the wheel + // again - the poll is destructive and the parent has already drained it. + int wheelDelta = listener instanceof GuiNPCInterface ? ((GuiNPCInterface) listener).mouseScroll : Mouse.getDWheel(); if (listener instanceof GuiNPCInterface) { - ((GuiNPCInterface) listener).mouseScroll = wheelDelta; + ((GuiNPCInterface) listener).mouseScroll = 0; // Intercept wheel scroll for tooltip (highest priority) // Only consume the wheel event when the tooltip actually has content to scroll; diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea1.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea1.java index 60e5a38a0..a5a555514 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea1.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea1.java @@ -486,9 +486,11 @@ public class GuiScriptTextArea1 extends GuiNpcTextField { int maxScroll = Math.max(0, getPaddedLineCount() - container.visibleLines); // Handle mouse wheel scroll - int wheelDelta = ((GuiNPCInterface) listener).mouseScroll = Mouse.getDWheel(); + // Take whatever the parent screen has left for this frame rather than polling the wheel + // again - the poll is destructive and the parent has already drained it. + int wheelDelta = listener instanceof GuiNPCInterface ? ((GuiNPCInterface) listener).mouseScroll : Mouse.getDWheel(); if (listener instanceof GuiNPCInterface) { - ((GuiNPCInterface) listener).mouseScroll = wheelDelta; + ((GuiNPCInterface) listener).mouseScroll = 0; boolean canScroll = !KEYS_OVERLAY.isVisible() || KEYS_OVERLAY.isVisible() && !KEYS_OVERLAY.aboveOverlay; if (wheelDelta != 0 && canScroll) scroll.applyWheelScroll(wheelDelta, maxScroll);