Formspec: Don't start a button click when the pointer isn't on top (#9332)

This commit is contained in:
Hugues Ross 2020-01-22 04:18:09 -05:00 committed by Loïc Blot
parent 0877587cce
commit 3dfb6ecbb2

@ -203,8 +203,12 @@ bool GUIButton::OnEvent(const SEvent& event)
case EET_MOUSE_INPUT_EVENT: case EET_MOUSE_INPUT_EVENT:
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) 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<s32>(event.MouseInput.X, event.MouseInput.Y ))) {
setPressed(true); setPressed(true);
}
return true; return true;
} }