-
I was attempting to create a grid of drag-and-drop zones, and I was setting it up like this: let drop_frame = egui::Frame::default()
.fill(egui::Color32::BLACK);
ui.dnd_drop_zone::<Location, ()>(drop_frame, |ui| { /* ... */ }) When I start dragging items around, I see that it overwrote my frame color. Looking at the documentation it says:
I tried: let drop_frame = egui::Frame::default()
.fill(egui::Color32::BLACK);
ui.dnd_drop_zone::<Location, ()>(drop_frame, |ui| {
ui.visuals_mut().widgets.inactive.bg_fill = egui::Color32::BLACK;
/* ... */
}) But the issue persists because it looks like Is there a reason it was done like this? I'm starting to think maybe I just need to create a context where |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The workaround looks like this: // Layout used to create an isolated context for style changes. May be a better way to do this.
ui.with_layout(egui::Layout::default(), |ui| {
// when `dnd_drop_zone` overrides color, it will use this
ui.visuals_mut().widgets.inactive.bg_fill = egui::Color32::TRANSPARENT;
// this will be the displayed color of the drop zone
let color_frame = egui::Frame::default().fill(egui::Color32::BLACK)
.show(ui, |ui| {
let drop_frame = egui::Frame::default();
// We have control over drop zone color
ui.dnd_drop_zone::<Location, ()>(drop_frame, |ui| { /* ... */ })
});
}); |
Beta Was this translation helpful? Give feedback.
The workaround looks like this: