Fix mouse wheel scrolling in the script editors

Mouse.getDWheel() clears the accumulated delta, so whichever widget polled it
first in a frame took it and every later reader saw zero. The script text areas
polled it themselves, after the parent screen had already drained it for its
scroll lists, so the wheel did nothing in the player, NPC and event script GUIs.
The screen now reads the wheel once per frame into the mouseScroll field it
already declared for this, and each widget zeroes it when it consumes it.
This commit is contained in:
KAMKEEL committed 2026-08-11 05:08:15 -04:00
1 parent 71bb4b451e
commit a028142dda
3 files changed
+23 -6

No files matched your search

@@ -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);