Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose .move_to_top for Window #800

Open
darthdeus opened this issue Oct 15, 2021 · 1 comment
Open

Expose .move_to_top for Window #800

darthdeus opened this issue Oct 15, 2021 · 1 comment

Comments

@darthdeus
Copy link

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.

image

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

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

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.

@PPakalns
Copy link
Contributor

PPakalns commented Nov 3, 2023

I had the same problem.

Answer provided in discussion worked for me.
#3493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants