Code Monkey home page Code Monkey logo

Comments (6)

Anut-py avatar Anut-py commented on June 21, 2024

raylib-python-cffi is probably out of date. All the controls were changed to return ints 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.

Anut-py avatar Anut-py commented on June 21, 2024

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.

raysan5 avatar raysan5 commented on June 21, 2024

@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.

furudbat avatar furudbat commented on June 21, 2024

@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 or active got changed
  • GuiTextBoxMulti returns an boolean (but GuiTextBox() returns int)
  • 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.

raysan5 avatar raysan5 commented on June 21, 2024

@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.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.