From fe1d96ed0ecb82e62f6d958aebc495996143d8c6 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 18 May 2021 14:58:29 -0300 Subject: [PATCH] Fix alternating through random colors when picking from the same ColorButton --- src/app/ui/color_button.cpp | 7 ++++++- src/app/ui/tile_button.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/ui/color_button.cpp b/src/app/ui/color_button.cpp index 40579b318..4caba893f 100644 --- a/src/app/ui/color_button.cpp +++ b/src/app/ui/color_button.cpp @@ -159,7 +159,12 @@ bool ColorButton::onProcessMessage(Message* msg) gfx::Point screenPos = nativeWindow->pointToScreen(mousePos); Widget* picked = manager()->pickFromScreenPos(screenPos); - IColorSource* colorSource = (picked != this ? dynamic_cast(picked): nullptr); + if (picked == this) { + // Do nothing + break; + } + + IColorSource* colorSource = dynamic_cast(picked); if (colorSource) { nativeWindow = picked->display()->nativeWindow(); mousePos = nativeWindow->pointFromScreen(screenPos); diff --git a/src/app/ui/tile_button.cpp b/src/app/ui/tile_button.cpp index f43c895ef..7658177c0 100644 --- a/src/app/ui/tile_button.cpp +++ b/src/app/ui/tile_button.cpp @@ -96,7 +96,12 @@ bool TileButton::onProcessMessage(Message* msg) // Pick a tile from a ITileSource Widget* picked = window()->pick(mousePos); - ITileSource* tileSource = (picked != this ? dynamic_cast(picked): nullptr); + if (picked == this) { + // Do nothing + break; + } + + ITileSource* tileSource = dynamic_cast(picked); // If there is no tile source in this window, try to get the // tile from other display, i.e. and editor in other native