From 2521929addbca88130c4ba0b3ab33dd4e0558088 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Dec 2024 08:50:28 +0100 Subject: [PATCH] Take layer order into account before hit-test --- crates/egui/src/context.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index f572899e4ac..ca18229d1ba 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -498,19 +498,8 @@ impl ContextImpl { viewport.this_pass.begin_pass(screen_rect); { - let area_order = self.memory.areas().order_map(); - let mut layers: Vec = viewport.prev_pass.widgets.layer_ids().collect(); - - layers.sort_by(|a, b| { - if a.order == b.order { - // Maybe both are windows, so respect area order: - area_order.get(a).cmp(&area_order.get(b)) - } else { - // comparing e.g. background to tooltips - a.order.cmp(&b.order) - } - }); + layers.sort_by(|&a, &b| self.memory.areas().compare_order(a, b)); viewport.hits = if let Some(pos) = viewport.input.pointer.interact_pos() { let interact_radius = self.memory.options.style().interaction.interact_radius;