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

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