OpenNBS / OpenNoteBlockStudio

An open-source Minecraft music maker.
https://opennbs.org/
MIT License
730 stars 50 forks source link

Releasing the mouse triggers a button even if the click wasn't initiated on it #372

Open Bentroen opened 1 year ago

Bentroen commented 1 year ago

The layer buttons (as well as most buttons across the program) are triggered when you release the mouse over the buttons, not when you press them down. This is to be consistent with UI buttons in general, since most of them allow you to cancel an action by moving the mouse cursor away from the button while the mouse click is still pressed down. That said, NBS detects any mouse release on top of the button as a click, even if the cursor wasn't hovering over the button when the mouse was pressed.

This causes unwanted clicks to be triggered when releasing the mouse on top of UI elements, such as:

In order to fix this issue, a check must be added during the mouse key-up event to verify that the click was initiated on the same element.

The following video by user Sticks Comix on Discord demonstrates the problem: https://medal.tv/pt/games/requested/clips/P3Uy9a1eDVCXm/NiKbCOOXpWPV