summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2020-02-26 12:18:05 +0100
committerGitHub <noreply@github.com>2020-02-26 12:18:05 +0100
commit0c08f948d7014e66d5a79d7584c03164af2edd93 (patch)
treeaad61362a2b7a16b9d233dbf0cc4839ec9b2ada4
parent244121b9643f91e1b8ffb4c37a255d7603da2116 (diff)
downloadminetest-0c08f948d7014e66d5a79d7584c03164af2edd93.tar.gz
minetest-0c08f948d7014e66d5a79d7584c03164af2edd93.tar.bz2
minetest-0c08f948d7014e66d5a79d7584c03164af2edd93.zip
GUIInventoryList: fix dropping items when clicking outside of formspec window (#9422)
-rw-r--r--src/gui/guiInventoryList.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gui/guiInventoryList.cpp b/src/gui/guiInventoryList.cpp
index ae7ec0539..536471229 100644
--- a/src/gui/guiInventoryList.cpp
+++ b/src/gui/guiInventoryList.cpp
@@ -176,7 +176,14 @@ bool GUIInventoryList::OnEvent(const SEvent &event)
Environment->getRootGUIElement()->getElementFromPoint(
core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y));
- bool ret = hovered && hovered->OnEvent(event);
+ // if the player clicks outside of the formspec window, hovered is not
+ // m_fs_menu, but some other weird element (with ID -1). we do however need
+ // hovered to be m_fs_menu as item dropping when clicking outside of the
+ // formspec window is handled in its OnEvent callback
+ if (!hovered || hovered->getID() == -1)
+ hovered = m_fs_menu;
+
+ bool ret = hovered->OnEvent(event);
IsVisible = was_visible;