Basic example doesn't work in eframe template, widgets aren't recognized
dRAT3 opened this issue · 9 comments
Hi, I cloned the eframe starter and tried to add the widgets to it by copying the basic example into my update function
let Self { label, value } = self;
// Examples of how to create different panels and windows.
// Pick whichever suits you.
// Tip: a good default choice is to just keep the `CentralPanel`.
// For inspiration and more examples, go to https://emilk.github.io/egui
#[cfg(not(target_arch = "wasm32"))] // no File->Quit on web pages!
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:
egui::menu::bar(ui, |ui| {
ui.menu_button("File", |ui| {
if ui.button("Quit").clicked() {
_frame.close();
}
});
});
});
egui::CentralPanel::default().show(ctx, |ui| {
// The central panel the region left after adding TopPanel's and SidePanel's
ui.heading("eframe template");
ui.hyperlink("https://github.com/emilk/eframe_template");
ui.add(egui::github_link_file!(
"https://github.com/emilk/eframe_template/blob/master/",
"Source code."
));
egui::warn_if_debug_build(ui);
});
egui::Window::new("My window")
.default_pos(pos2(20.0, 100.0))
.show(ctx, |ui| {
ui.add(Port::new(0));
});
egui::Window::new("My window 2")
.default_pos(pos2(200.0, 20.0))
.show(ctx, |ui| {
ui.add(Port::new(1));
ui.add_space(10.0);
ui.add(Port::new(2));
});
egui::Window::new("My window 3")
.default_pos(pos2(200.0, 200.0))
.show(ctx, |ui| {
ui.add(Port::new(3));
ui.add(Cable::new(0, Plug::to(0), Plug::to(1)));
ui.add(Cable::new(1, Plug::to(0), Plug::to(3)));
ui.add(Cable::new(2, Plug::to(2), Plug::unplugged()));
});
}
}
But then I get the error:
error[E0277]: expected a `FnOnce<(&mut egui::Ui,)>` closure, found `egui_cable::port::Port`
--> src/app.rs:85:24
|
85 | ui.add(Port::new(0));
| --- ^^^^^^^^^^^^ expected an `FnOnce<(&mut egui::Ui,)>` closure, found `egui_cable::port::Port`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'a> FnOnce<(&'a mut egui::Ui,)>` is not implemented for `egui_cable::port::Port`
= help: the following other types implement trait `egui::Widget`:
&eframe::epaint::PaintStats
&mut eframe::epaint::TessellationOptions
egui::Button
egui::Checkbox<'a>
egui::DragValue<'a>
egui::Hyperlink
egui::Image
egui::ImageButton
and 9 others
= note: required for `egui_cable::port::Port` to implement `egui::Widget`
note: required by a bound in `egui::Ui::add`
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/egui-0.21.0/src/ui.rs:1055:40
|
1055 | pub fn add(&mut self, widget: impl Widget) -> Response {
| ^^^^^^ required by this bound in `egui::Ui::add`
I get the same error for all the egui_cable widgets.
Do you have any idea what I might've done wrong or if it is a bug?
I am on version 0.4.0 from crates I'll try on 0.3.1
@dRAT3 Then, please ensure the version of egui
depended by egui_cable
is the same as the one you are using.
Oh I may had a mistake of the versioning
I’ll fix the wrong versioning and other things later. It should be done before about 3 hours later.
To be shure I used
egui_cable = { git = "https://github.com/ryo33/egui_cable", branch = "main" }
and now I run into 43 errors inside the egui_cable package
Okay thanks I'll check back in a couple of hours
@dRAT3 Sorry for late. It takes longer than imagined to follow the latest egui's API. It should be finished in a day. For now, I'm going to sleep...zzz
For now, can you downgrade the egui to the former version, 0.20
? It should work even now.
Yes for shure, no problem at all, thx matey