Can you generically render Widgets? #7302
-
|
You can have I'm trying to have generically add widgets. fn ui(self, ui: &mut Ui) -> Response;dyn Widget are unsized, and they take self by value instead of by reference. Hence you cannot use dyn objects. |
Beta Was this translation helpful? Give feedback.
Answered by
codecnotsupported
Jul 5, 2025
Replies: 1 comment
-
pub trait Widget {
fn render(&mut self, ui: &mut egui::Ui);
}I just made another Trait to render UI element, feels as if this should be part of Egui, but I didn't RTFM. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
codecnotsupported
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just made another Trait to render UI element, feels as if this should be part of Egui, but I didn't RTFM.