redox-os / orbtk

The Rust UI-Toolkit.
MIT License
3.78k stars 188 forks source link

ComboBox changes does not trigger on_changed callback #296

Closed uniformbuffer closed 4 years ago

uniformbuffer commented 4 years ago

Describe the bug When the selected item of a ComboBox is changed, the on_changed callback is not called.

To Reproduce I have made a little example:

use orbtk::prelude::*;

fn main() {
    Application::new()
        .window(|ctx| {
            Window::new()
                .title("Test")
                .position((100.0, 100.0))
                .size(700.0, 500.0)
                .resizeable(true)
                .child(
                    ComboBox::new()
                    .v_align("center")
                    .h_align("center")
                    .on_changed(move |_states, _entity, property| {
                        println!("Changed {}",property);
                    })
                    .items_builder(|bc,index|{
                        match index {
                            0 => TextBlock::new().text("Bottom").build(bc),
                            1 => TextBlock::new().text("Top").build(bc),
                            2 => TextBlock::new().text("Left").build(bc),
                            3 => TextBlock::new().text("Right").build(bc),
                            _ => panic!()
                        }
                    })
                    .count(4)
                    .selected_index(0)
                    .build(ctx)
                )
                .build(ctx)
        })
        .run();
}

This should print "Changed {property name}" every time a property of the ComboBox change, but nothing is printed.

Expected behavior When a ComboBox property is changed, an on_changed callback should be triggered.

Desktop (please complete the following information):

Additional context Seem to be the same problem that happen to NumericBox, maybe have the same root?

FloVanGH commented 4 years ago

fixed

uniformbuffer commented 4 years ago

Thanks!