Skip to content

bevy_feathers: It is impossible to initialize a checkbox with a variable #23178

@Warhorst

Description

@Warhorst

Bevy version and features

  • 0.18
  • ["2d", "dynamic_linking", "bevy_dev_tools", "experimental_bevy_ui_widgets", "experimental_bevy_feathers"]

What you did

I tried to create a feathers checkbox and initialize it with a boolean variable. This is currently not possible

What went wrong

I tried to do something like this:

fn create_checkbox(checked: bool) -> impl Bundle {
    checkbox(??? , Spawn(Text::new("Checkbox")))
}

The checkbox state gets set based on the bundle provided to it. So I provide Checked to set it checked or () to set it not checked.

But what do I do if I want to set it checked based on the provided variable? Something like the following does not work:

fn create_checkbox(checked: bool) -> impl Bundle {
    let bundle = if checked {
         Checked
    } else {
        ()
    };

    checkbox(bundle , Spawn(Text::new("Checkbox")))
}

This does not compile, as the branches have different types.

I would expect that I could just initialize the checkbox like the Slider, where I put all the properties into a properties component (like SliderProps). The doc of the checkbox function even mentions a third parameter named props, which does not exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsA-UIGraphical user interfaces, styles, layouts, and widgetsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-BlockedThis cannot move forward until something else changes

    Type

    No type

    Projects

    Status

    Needs SME Triage

    Status

    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions