From 6a55c03dabf7b5337233fc80078a300d485fcec4 Mon Sep 17 00:00:00 2001 From: Vincent Robinson Date: Sat, 23 Jan 2021 14:48:57 -0800 Subject: [PATCH] Make hypertext and textarea have proper scroll event propagation. (#10860) --- games/devtest/mods/testformspec/formspec.lua | 2 ++ src/gui/guiEditBox.cpp | 1 + src/gui/guiHyperText.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/games/devtest/mods/testformspec/formspec.lua b/games/devtest/mods/testformspec/formspec.lua index 0eef859a9..62578b740 100644 --- a/games/devtest/mods/testformspec/formspec.lua +++ b/games/devtest/mods/testformspec/formspec.lua @@ -220,6 +220,8 @@ local scroll_fs = "tooltip[0,11;3,2;Buz;#f00;#000]".. "box[0,11;3,2;#00ff00]".. "hypertext[3,13;3,3;;" .. hypertext_basic .. "]" .. + "hypertext[3,17;3,3;;Hypertext with no scrollbar\\; the scroll container should scroll.]" .. + "textarea[3,21;3,1;textarea;;More scroll within scroll]" .. "container[0,18]".. "box[1,2;3,2;#0a0a]".. "scroll_container[1,2;3,2;scrbar2;horizontal;0.06]".. diff --git a/src/gui/guiEditBox.cpp b/src/gui/guiEditBox.cpp index 1214125a8..79979dbc3 100644 --- a/src/gui/guiEditBox.cpp +++ b/src/gui/guiEditBox.cpp @@ -787,6 +787,7 @@ bool GUIEditBox::processMouse(const SEvent &event) s32 pos = m_vscrollbar->getPos(); s32 step = m_vscrollbar->getSmallStep(); m_vscrollbar->setPos(pos - event.MouseInput.Wheel * step); + return true; } break; default: diff --git a/src/gui/guiHyperText.cpp b/src/gui/guiHyperText.cpp index 88931cdf9..ccfdcb81d 100644 --- a/src/gui/guiHyperText.cpp +++ b/src/gui/guiHyperText.cpp @@ -1088,7 +1088,7 @@ bool GUIHyperText::OnEvent(const SEvent &event) if (event.MouseInput.Event == EMIE_MOUSE_MOVED) checkHover(event.MouseInput.X, event.MouseInput.Y); - if (event.MouseInput.Event == EMIE_MOUSE_WHEEL) { + if (event.MouseInput.Event == EMIE_MOUSE_WHEEL && m_vscrollbar->isVisible()) { m_vscrollbar->setPos(m_vscrollbar->getPos() - event.MouseInput.Wheel * m_vscrollbar->getSmallStep()); m_text_scrollpos.Y = -m_vscrollbar->getPos();