1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

eframe: read the state of native window's input focus and request it (#2900)

* Add ability to read the native window's focus state

* Add `eframe::Frame::focus()` for requesting the native window's focus

* rename the output field `active` → `focused` for consistency
This commit is contained in:
TicClick
2023-04-18 15:03:06 +02:00
committed by GitHub
parent b80c0e6ff6
commit 6f1e66731e
2 changed files with 22 additions and 0 deletions

View File

@@ -61,6 +61,7 @@ pub fn read_window_info(
fullscreen: window.fullscreen().is_some(),
minimized: window_state.minimized,
maximized: window_state.maximized,
focused: window.has_focus(),
size: egui::Vec2 {
x: size.width,
y: size.height,
@@ -231,6 +232,7 @@ pub fn handle_app_output(
screenshot_requested: _, // handled by the rendering backend,
minimized,
maximized,
focus,
} = app_output;
if let Some(decorated) = decorated {
@@ -284,6 +286,10 @@ pub fn handle_app_output(
window.set_maximized(maximized);
window_state.maximized = maximized;
}
if focus == Some(true) {
window.focus_window();
}
}
// ----------------------------------------------------------------------------