-
I have a simple popup to set target ips, in which i have a ComboBox to select the network interface. Is this intended or is this something that is gonna change? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
For now i fixed it by making it user-unfriendly and letting the user cycle through the available interfaces / addresses. |
Beta Was this translation helpful? Give feedback.
-
It is intentional, or at least it is documented. One workaround is to use a struct MyApp {
name: String,
age: u32,
}
impl Default for MyApp {
fn default() -> Self {
Self {
name: "Arthur".to_owned(),
age: 42,
}
}
}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
let clicked = ui
.horizontal(|ui| {
ui.label(format!("{}, {}", self.name, self.age));
ui.button("Edit").clicked()
})
.inner;
let editing: bool = ui
.data(|data| data.get_temp("editing".into()))
.unwrap_or(false)
|| clicked;
if editing {
let mut combo_box_clicked = false;
let clicked_outside = egui::Window::new("Choices")
.collapsible(false)
.show(ui.ctx(), |ui| {
combo_box_clicked |= egui::ComboBox::from_label("Name")
.selected_text(self.name.as_str())
.show_ui(ui, |ui| {
ui.selectable_value(&mut self.name, "Alice".to_owned(), "Alice")
| ui.selectable_value(&mut self.name, "Bob".to_owned(), "Bob")
| ui.selectable_value(
&mut self.name,
"Carol".to_owned(),
"Carol",
)
})
.inner
.map_or(false, |r| r.clicked());
ui.add(egui::DragValue::new(&mut self.age));
})
.map_or(true, |r| r.response.clicked_elsewhere());
let close = clicked_outside & !combo_box_clicked;
ui.data_mut(|data| data.insert_temp("editing".into(), !close || clicked));
}
});
}
} Screencast.from.2024-05-06.21-00-02.webmYou may want to tweak some things to make it look more like a popup, like removing the title bar, pinning the position etc. |
Beta Was this translation helpful? Give feedback.
It is intentional, or at least it is documented.
One workaround is to use a
Window
: