Replies: 1 comment 1 reply
-
The change is valid within the current UI scope. Example: use eframe::{egui, epaint::Color32};
fn main() -> Result<(), eframe::Error> {
eframe::run_native(
"My egui App",
Default::default(),
Box::new(|_cc| Box::<MyApp>::default()),
)
}
#[derive(Default)]
struct MyApp {}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.scope(|ui| {
ui.style_mut().visuals.widgets.hovered.weak_bg_fill = Color32::RED;
ui.button("Red");
ui.button("Still red");
ui.style_mut().visuals.widgets.hovered.weak_bg_fill = Color32::BLUE;
ui.button("Blue");
});
ui.button("Default");
});
}
} Screencast.from.2023-09-21.19-59-21.webmOther methods are being planned, like #3284, but currently this is the way to do it. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Do you have a simple method to be able to change button color in a simple way ?
Beta Was this translation helpful? Give feedback.
All reactions