-
-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GuiToggle()
always returns 0
#371
Comments
raylib-python-cffi is probably out of date. All the controls were changed to return |
Actually this does seem inconsistent; |
@SirNate0 @Anut-py Latest Help and feedback on this improvements are welcome! |
I also noticed this, (in the old behavior it was something like this "return 1 when clicked", the newer version broke some code of mine) Would be nice if the Gui-Elements returns they are also "render-only" Gui-Elements with For // Check toggle button state
if (CheckCollisionPointRec(mousePoint, bounds))
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{
state = STATE_PRESSED;
result = 1;
}
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
{
state = STATE_NORMAL;
*active = !(*active);
result = 1;
}
else state = STATE_FOCUSED;
} For something like
If some value changed or the user interact with the Gui-Element, I can do something like this: if(GuiButton(...)) { ... }
if (GuiToggle(...)) {
// do stuff with change toggle value
}
if (GuiTextBox(...)) {
}
// some special cases ...
if (GuiDropdownBox(....)) {
case 1:
// item got selected (clicked)
break;
case 2:
// clicked out-of-box, "close" DropdownBox
break;
} I'm sure enums can help as results: typedef enum {
TEXTBOX_CLICKED = 1
} GuiTextBoxResult; |
@furudbat Thanks for the review! Actually, I would like to find a consistent convention between all controls in that regards. For example: typedef enum GuiControlResult {
RESULT_NONE = 0,
RESULT_FOCUSED = 1,
RESULT_CLICKED = 2,
RESULT_SCROLLED = 3,
RESULT_CUSTOM01 = 4,
RESULT_CUSTOM02 = 5,
} GuiControlResult; But every control has to be carefully analized to see what are the possible internal states that could be returned. It would be nice to unify the possible return values but also allow per-control custom return values. Your controls list with a potential return state is a good start. |
Opened a separate issue to review. |
raygui/src/raygui.h
Lines 2025 to 2071 in 45e7f96
Not sure if it's a bug or not. The documentation seems to have changed from the version used with the raylib-python-cffi, but those docs made it seem like it should return true when active.
The text was updated successfully, but these errors were encountered: