Formspec: Don't start a button click when the pointer isn't on top #9332
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially resolves #9330 by preventing buttons from entering pressed state from a click event if the mouse is somewhere else. The GUIButton code already checks if the mouse is over it on release, so I've simply added a second check on press.
Limitations
As mentioned above, this fix is only for buttons. I expect that any formspec element receiving mouse clicks can be affected by this (I can confirm that this affects
dropdown
elements as well, which appear to be a builtin Irrlicht gui element), and honestly the ideal would be to fix the issue at the source... However, I get the impression that this might be an Irrlicht bug so workarounds might be the best we can do.Testing
To test, just open a formspec and click any button once to make it active. After that, click outside of the formspec window and remark that it doesn't get pressed. I've taken the liberty of testing how this interacts with buttons clipping with the window, this works on my end but you should probably test it as well.