#Egui: Adding ui-elements to windows already created in other function

7 messages · Page 1 of 1 (latest)

bright summit
#

If I have created an egui window

egui::Window::new("My Window")
    .show(egui_ctx, |ui| {
        ui.label("Hello, world!");
    });

How can I add more widgets to that window later from another function?

dusky jasper
#

Egui's immediate mode API means you kinda have to do all your widget rendering inside that function

#

You can pass in a closure perhaps

#

(one of the reasons I'm not a fan of immediate mode tbh)

bright summit
#

Hmm... Thanks! That's unfortunate.

dusky jasper
#

You could build your own retained mode layer

#

Make a struct representing the state of the window, then have the rendering function process that to decide what to draw