create widgets_ontop

This commit is contained in:
Simon Gardling
2022-04-20 11:20:43 -04:00
parent 0336a34e40
commit 9afa4d86bc
3 changed files with 59 additions and 45 deletions

View File

@@ -100,6 +100,17 @@ pub fn move_cursor_to_end(ctx: &egui::Context, te_id: egui::Id) {
TextEdit::store_state(ctx, te_id, state);
}
pub fn widgets_ontop<R>(
ui: &egui::Ui, id: String, re: &egui::Response, y_offset: f32,
add_contents: impl FnOnce(&mut egui::Ui) -> R,
) -> R {
let area = egui::Area::new(id)
.fixed_pos(re.rect.min.offset_y(y_offset))
.order(egui::Order::Foreground);
area.show(ui.ctx(), |ui| add_contents(ui)).inner
}
#[cfg(test)]
mod autocomplete_tests {
use super::*;