Comments (6)
raylib-python-cffi is probably out of date. All the controls were changed to return int
s as status values (i.e. 1 or 0). In this case the status value is always 0. You should use active
to get the toggle state.
from raygui.
Actually this does seem inconsistent; GuiMessageBox
for example returns the clicked index instead of using a pointer. Maybe this needs to be redesigned to be more consistent.
from raygui.
@SirNate0 @Anut-py Latest raygui 4.0
release was a big redesign of the library moving all controls data from return values to function parameters and return values were left for internal control states values required by users. This is still under design trying to find a common pattern for all controls on what kind of info should be returned (i.e. Mouse states over control, focus state, specific required states to be exposed...)
Help and feedback on this improvements are welcome!
from raygui.
@SirNate0 @Anut-py Latest
raygui 4.0
release was a big redesign of the library moving all controls data from return values to function parameters and return values were left for internal control states values required by users. This is still under design trying to find a common pattern for all controls on what kind of info should be returned (i.e. Mouse states over control, focus state, specific required states to be exposed...)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 1
when clicked or interact with, some sort of "onChange"-Event.
they are also "render-only" Gui-Elements with int
as result. (like GuiGroupBox
, GuiLabel
, ...)
those can also return 1 when clicked, maybe enable this feature via macro (?)
For GuiToggle
, it can return 1
when clicked:
// 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 GuiToggleGroup
, it can be "number of GuiToggle interact": result += GuiToggle(bounds, items[i], &toggle);
.
GuiScrollPanel
can return 1 when scrolled.GuiComboBox
also didn't return anything, return 1 when clicked oractive
got changedGuiTextBoxMulti
returns an boolean (butGuiTextBox()
returnsint
)GuiDummyRec
always returns 0 ???GuiListViewEx/GuiListView
result ???, return 1 when clicked, return 2 when scrolled ... (?)GuiColorPanel
didn't return anything, return 1 when change color (?)GuiWindowBox
can return different values. "clicked-in-box" (2), close window (1), ...
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;
from raygui.
@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.
from raygui.
Opened a separate issue to review.
from raygui.
Related Issues (20)
- Multiple `GuiTextInputBox()` not supported HOT 2
- [`rGuiStyler`] Support for substepping font rasterization HOT 3
- examples build issue HOT 1
- `GuiButton()` not considering mouse state as exclusive mode HOT 2
- Dynamic depth management HOT 4
- Input blocking / input event consuming HOT 2
- [Feature Request] Keyboard Navigation HOT 2
- Error - cannot convert bool* to int* HOT 1
- [Feature Request] Accessibility support? HOT 5
- Problem with Installation HOT 1
- Problem when define HOT 2
- Documentation on the `rgs` format HOT 2
- Issue with Unicode input on `GuiTextBox()` HOT 1
- Compile for Rapberry Pi 2B HOT 3
- Raspberry Pi - touch does not works. HOT 3
- Define a consistent convention on controls return values
- missing .c file in src ? HOT 2
- GuiLoadIcons example? HOT 4
- ``TextToFloat`` was not declared in this scope when compiling a raygui program HOT 8
- Multiple definitions of raygui functions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raygui.