REVIEWED: GuiCheckBox() #330

return internal-state: 1->Value changed in the control
This commit is contained in:
Ray
2023-09-12 14:42:05 +02:00
parent 25c8c65a6e
commit 1c3305031d

View File

@ -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;
}
}
}
//--------------------------------------------------------------------