Map Editor terrain button click fix (#9560)

Fixed palette button not being clickable after scrolling in palette widget without moving the cursor. Resolves #1335. The cause of the bug was that scrolling doesnt change the highlighted state of the palette buttons and not highlighted buttons didnt process being clicked. Solved the bug by making not highlighted buttons process being clicked.
This commit is contained in:
Tóth Kornél 2024-11-19 15:20:30 +01:00 committed by GitHub
parent 5d3a84084e
commit 484116ea09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -307,17 +307,18 @@ void tristate_button::mouse_down(const SDL_MouseButtonEvent& event) {
if (!hit(event.x, event.y))
return;
//The widget is expected to be in one of the "active" states when the mouse cursor is hovering over it, but that currently doesn't happen if the widget is moved under the cursor by scrolling the palette.
if (event.button == SDL_BUTTON_RIGHT) {
if (state_ == ACTIVE)
if (state_ == ACTIVE || state_ == NORMAL)
state_ = TOUCHED_RIGHT;
if (state_ == PRESSED_ACTIVE_LEFT)
if (state_ == PRESSED_ACTIVE_LEFT || state_ == PRESSED_LEFT)
state_ = TOUCHED_BOTH_LEFT;
}
if (event.button == SDL_BUTTON_LEFT) {
if (state_ == ACTIVE)
if (state_ == ACTIVE || state_ == NORMAL)
state_ = TOUCHED_LEFT;
if (state_ == PRESSED_ACTIVE_RIGHT)
if (state_ == PRESSED_ACTIVE_RIGHT || state_ == PRESSED_RIGHT)
state_ = TOUCHED_BOTH_RIGHT;
}