diff options
author | Hugues Ross <hugues.ross@gmail.com> | 2020-01-22 04:18:09 -0500 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2020-01-22 10:18:09 +0100 |
commit | 3dfb6ecbb26516bcbcc1ef88860175e39af71381 (patch) | |
tree | e1d6bd74fec5658c6277529dea62645ea72e4964 /src/gui | |
parent | 0877587cce1d96b1c8c009221684ab382e8f1929 (diff) | |
download | minetest-3dfb6ecbb26516bcbcc1ef88860175e39af71381.tar.gz minetest-3dfb6ecbb26516bcbcc1ef88860175e39af71381.tar.bz2 minetest-3dfb6ecbb26516bcbcc1ef88860175e39af71381.zip |
Formspec: Don't start a button click when the pointer isn't on top (#9332)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/guiButton.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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<s32>(event.MouseInput.X, event.MouseInput.Y ))) {
setPressed(true);
+ }
return true;
}
|