I'm having trouble getting this to work based on the menu example in iced_aw. Specifically, I attempted to implement it, but I'm encountering an issue where menu_items cannot be passed to menu_tpl_1((menu_items)).
The compiler is giving me the following error:
a value of type `Vec<icedaw::menu::Item<', , , >> cannot be built from an iterator over elements of type iced::widget::Button<', {closure@src/views/hardwareview.rs:575:65: 575:72}, , >
Below is the implementation:
let mut pin_options_row = Row::new().align_items(Alignment::Center);
let menu_tpl_1 = |items| menu::Menu::new(items).max_width(180.0).offset(15.0).spacing(5.0);
let bcm_pin_number = pin_description.bcm_pin_number.unwrap();
let choices: &[PinFunction] = pin_description.options;
let selected = selected_function.unwrap_or(&PinFunction::None);
let menu_items = choices.iter().map(|choice| {
Button::new(Text::new(choice.to_string())).on_press(move || {
HardwareMessage::PinFunctionSelected(bcm_pin_number, choice.clone())
})
}).collect();
let mb = menu_bar!((Button::new(Text::new(selected.to_string())), {
menu_tpl_1((menu_items))
}));
pin_options_row = pin_options_row.push(mb);
I don't know any other way to implement this.
Any help is much appreciated!
Thx in advance!
I'm having trouble getting this to work based on the menu example in iced_aw. Specifically, I attempted to implement it, but I'm encountering an issue where menu_items cannot be passed to menu_tpl_1((menu_items)).
The compiler is giving me the following error: a value of type `Vec<icedaw::menu::Item<', , , >> cannot be built from an iterator over elements of type iced::widget::Button<', {closure@src/views/hardwareview.rs:575:65: 575:72}, , >
Below is the implementation:
I don't know any other way to implement this. Any help is much appreciated! Thx in advance!