Expose `.move_to_top` for `Window`
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
**Is your feature request related to a problem? Please describe.**
I'm drawing multiple windows which expand their contents on hover (screenshot). The problem is in setting which window is rendered on top.

I tried changing the order in which `window.show(...)` is called but it seems as long as they have the same IDs their z-order remains the same.
I also tried using `ui.with_layer_id` but this doesn't work for the windows themselves, as in
```rust
Window::new(...).show(|ui| {
ui.with_layer_id(...);
})
```
What I noticed happens is clicking on a window puts it in front of all other windows. I tried using `ui.request_focus()` but this also doesn't work.
The only solution I found digging into egui's source code is
```rust
let window = Window::new(...);
ctx.memory().areas.move_to_top(window.area.layer());
window.show(ctx, |ui| { ... });
```
but the problem is `memory().areas` and `window.area` are both private fields. I did this by just making them public with a crate override, but there probably is a reason for them being not directly accessible.
**Describe the solution you'd like**
Expose an API for `Window` that enables moving it to the front like `areas.move_to_top()` does.
**Describe alternatives you've considered**
I've considered simulating a click on the window, but couldn't find an easy way of doing this. It seems `.move_to_top()` is only called based on interaction events, but since in my case the UI actually responds to a click I would need to do something more complicated.
In my case clicking removes the item & window, so the only way to move it to the front is click & hold, move the mouse away, and release, which moves the window to the front without triggering click.
Contributor guide
Research direction
Start by reading Window::show and the existing ctx.memory().areas.move_to_top(window.area.layer()) path described in the issue, including how interaction events trigger it. Trace the relevant Window and area ownership boundaries, then define and verify a public Window-level API that brings the window to the front without requiring private fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100