From 25f1730ae3799d0ea438649949b0a32f38bce5ce Mon Sep 17 00:00:00 2001 From: ChrisDill Date: Wed, 26 Sep 2018 14:23:28 +0100 Subject: [PATCH] Only run dropdown collision check if dropdown open - Added static bool dropOpen to track if the dropdown is currently open. - Fixes bug where dropdown would change when closed if a element that overlaps is pressed. --- src/raygui.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/raygui.h b/src/raygui.h index 0cca6f7..0a961e0 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -1616,6 +1616,7 @@ RAYGUIDEF int GuiDropdownBox(Rectangle bounds, const char **text, int count, int GuiControlState state = guiState; bool dropActive = false; + static bool dropOpen = false; static bool clicked = false; int textWidth = MeasureText(text[active], style[DEFAULT_TEXT_SIZE]); @@ -1642,6 +1643,7 @@ RAYGUIDEF int GuiDropdownBox(Rectangle bounds, const char **text, int count, int { bounds.height *= (count + 1); dropActive = true; + dropOpen = true; } if (CheckCollisionPointRec(mousePoint, bounds)) @@ -1651,7 +1653,7 @@ RAYGUIDEF int GuiDropdownBox(Rectangle bounds, const char **text, int count, int } else state = NORMAL; - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON) && dropOpen) { for (int i = 1; i < (count + 1); i++) {