diff --git a/crates/egui/src/containers/popup.rs b/crates/egui/src/containers/popup.rs index 5f4a9d6203a..b0aad3636b2 100644 --- a/crates/egui/src/containers/popup.rs +++ b/crates/egui/src/containers/popup.rs @@ -302,10 +302,16 @@ pub fn popup_above_or_below_widget( add_contents: impl FnOnce(&mut Ui) -> R, ) -> Option { if parent_ui.memory(|mem| mem.is_popup_open(popup_id)) { - let (pos, pivot) = match above_or_below { + let (mut pos, pivot) = match above_or_below { AboveOrBelow::Above => (widget_response.rect.left_top(), Align2::LEFT_BOTTOM), AboveOrBelow::Below => (widget_response.rect.left_bottom(), Align2::LEFT_TOP), }; + if let Some(transform) = parent_ui + .ctx() + .memory(|m| m.layer_transforms.get(&parent_ui.layer_id()).copied()) + { + pos = transform * pos; + } let frame = Frame::popup(parent_ui.style()); let frame_margin = frame.total_margin(); diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index 01c3e2bf213..2b8ed3a4579 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -363,6 +363,13 @@ impl MenuRoot { } } + if let Some(transform) = button + .ctx + .memory(|m| m.layer_transforms.get(&button.layer_id).copied()) + { + pos = transform * pos; + } + return MenuResponse::Create(pos, id); } else if button .ctx diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index 192c573ff16..bb3d6456b88 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -562,7 +562,14 @@ impl Response { /// /// This can be used to give attention to a widget during a tutorial. pub fn show_tooltip_ui(&self, add_contents: impl FnOnce(&mut Ui)) { - crate::containers::show_tooltip_for(&self.ctx, self.id, &self.rect, add_contents); + let mut rect = self.rect; + if let Some(transform) = self + .ctx + .memory(|m| m.layer_transforms.get(&self.layer_id).copied()) + { + rect = transform * rect; + } + crate::containers::show_tooltip_for(&self.ctx, self.id, &rect, add_contents); } /// Always show this tooltip, even if disabled and the user isn't hovering it.