Skip to content

nk_option_text return value inconsistant #853

@StewBC

Description

@StewBC

The nk_option_text return value is inconsistant, based on whether the widget is on- or off-screen.

nk_option_text will return 0 (state), if the widget is not on-screen.
It will return is_active (the widget select state, after processing) when the widget is on-screen.

Instead of returning state when off-screen, it should return is_active. There's no way to know from the call that the reason it is returning 0 is because the widget was off-screen.

The code, I think, should read:
state = nk_widget(&bounds, ctx);
if (!state) return (int)is_active; // this is currently: if (!state) return (int)state;

This will return a "proper" state, whether drawn or not.

Currently, the following code will not work because my_bool will become 0 if the widget is off-screen.
my_bool = nk_option_text(ctx, "bool" my_bool);

With the suggested change, my_bool is only altered if the users alters the state of the widget.

The same holds true for nk_option_text_align

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions