If I have a widget, say a checkbox, in a panel in an egui/frame application, and I want something in a different panel whose behaviour depends on the value of that checkbox, is there either a direct way of accessing this value from one widget to the other, or a recommended/documented pattern to do this?
At the moment I'm achieving what I want by having variables in the widget that needs to read the values, and pass those from the main app code. It works, but it seems convoluted and mostly boiler plate. Given there's context, memory, ui, ... and widgets get names, I'm hoping there's a way of sharing info across widgets via any of these, but can't quite figure out how.
When using eframe, a common pattern is to put all of the program's state as fields on the struct implementing the
eframe::Apptrait and writing functions containing GUI code as member functions of that struct. This is what the official eframe_template does.For example:
src/main.rsCargo.tomlResult:
screenshot