0

I'm writing a calendar like todo app using Rust egui with eframe. Each todo is a combination of different widgets (text_edit_singleline and two buttons) How do I add a new todo when pressing a third button. Thank you in advance.

I already tried to integrate a new widget in:

if ui.button("ADD TODO").clicked() {
    // add todo
}

But then the new widget only appears for a couple of frames.

Mujk
  • 1
  • 1

1 Answers1

1

egui follows the immediate UI paradigm. As such there are no "persisent" widget objects. Instead for each redraw of the window, everything you see is regenerated from scratch (some immediate UI libraries implement some internal form of caching to avoid recalculating everything).

Anyway, in your case you'd add to the container (list, vector, etc.) that holds the ToDo items an additional one. And then on the next pass of the UI code, it would also iterate over that and hence draw it then.

datenwolf
  • 159,371
  • 13
  • 185
  • 298