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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user