From: Hugues Ross Date: Wed, 22 Jan 2020 09:18:09 +0000 (-0500) Subject: Formspec: Don't start a button click when the pointer isn't on top (#9332) X-Git-Tag: 5.2.0~224 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3dfb6ecbb26516bcbcc1ef88860175e39af71381;p=oweals%2Fminetest.git Formspec: Don't start a button click when the pointer isn't on top (#9332) --- diff --git a/src/gui/guiButton.cpp b/src/gui/guiButton.cpp index 0d69ff143..ed79999cf 100644 --- a/src/gui/guiButton.cpp +++ b/src/gui/guiButton.cpp @@ -203,8 +203,12 @@ bool GUIButton::OnEvent(const SEvent& event) case EET_MOUSE_INPUT_EVENT: if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) { - if (!IsPushButton) + // Sometimes formspec elements can receive mouse events when the + // mouse is outside of the formspec. Thus, we test the position here. + if ( !IsPushButton && AbsoluteClippingRect.isPointInside( + core::position2d(event.MouseInput.X, event.MouseInput.Y ))) { setPressed(true); + } return true; }