Browse Source

REVIEWED: `GuiCheckBox()` #330

return internal-state: 1->Value changed in the control
Ray 2 years ago
parent
commit
1c3305031d
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/raygui.h

+ 6 - 2
src/raygui.h

@@ -2189,7 +2189,7 @@ int GuiToggleSlider(Rectangle bounds, const char *text, int *active)
     return result;
 }
 
-// Check Box control, returns true when active
+// Check Box control, returns 1 when state changed
 int GuiCheckBox(Rectangle bounds, const char *text, bool *checked)
 {
     int result = 0;
@@ -2228,7 +2228,11 @@ int GuiCheckBox(Rectangle bounds, const char *text, bool *checked)
             if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
             else state = STATE_FOCUSED;
 
-            if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) *checked = !(*checked);
+            if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
+            {
+                *checked = !(*checked);
+                result = 1;
+            }
         }
     }
     //--------------------------------------------------------------------