raysan5 / raygui

A simple and easy-to-use immediate-mode gui library
zlib License
3.36k stars 289 forks source link

GuiToggle's doc incorrectly states the return-value will be true when active #345

Closed tobyhinloopen closed 7 months ago

tobyhinloopen commented 11 months ago
// Basic controls set
RAYGUIAPI int GuiLabel(Rectangle bounds, const char *text);                                            // Label control, shows text
RAYGUIAPI int GuiButton(Rectangle bounds, const char *text);                                           // Button control, returns true when clicked
RAYGUIAPI int GuiLabelButton(Rectangle bounds, const char *text);                                      // Label button control, show true when clicked
RAYGUIAPI int GuiToggle(Rectangle bounds, const char *text, bool *active);                             // Toggle Button control, returns true when active
RAYGUIAPI int GuiToggleGroup(Rectangle bounds, const char *text, int *active);                         // Toggle Group control, returns active toggle index
RAYGUIAPI int GuiToggleSlider(Rectangle bounds, const char *text, int *active);                        // Toggle Slider control, returns true when clicked
RAYGUIAPI int GuiCheckBox(Rectangle bounds, const char *text, bool *checked);                          // Check Box control, returns true when active
RAYGUIAPI int GuiComboBox(Rectangle bounds, const char *text, int *active);                            // Combo Box control, returns selected item index

GuiButton returns a non-zero value when clicked, but GuiToggle always returns 0. The docs are a bit unclear on that, and the signature is misleading (because it returns an int).

My suggestion is to do one of these options:

I'm fine with providing a PR with any of these suggestions, if you let me know if you're okay with any of these suggestions.

raysan5 commented 7 months ago

Docs updated! Related issue with more details: https://github.com/raysan5/raygui/issues/359

tobyhinloopen commented 7 months ago

Thanks!