GUIInventoryList: fix dropping items when clicking outside of formspec window (#9422)
authorDS <vorunbekannt75@web.de>
Wed, 26 Feb 2020 11:18:05 +0000 (12:18 +0100)
committerGitHub <noreply@github.com>
Wed, 26 Feb 2020 11:18:05 +0000 (12:18 +0100)
src/gui/guiInventoryList.cpp

index ae7ec0539f31badf95931df67f08b8022fa7f044..53647122963eb5952048734598304548b391f5d1 100644 (file)
@@ -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;