egui
egui copied to clipboard
InputState.screen_rect on Windows does not have position
Describe the bug According to the docs: InputState.screen_rect: Position and size of the egui area.
However, this code:
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let ui_size = ctx.input(|i: &egui::InputState| i.screen_rect());
info!("ui_size: {ui_size:?}");
...always reports an origin of [0.0 0.0] when dragging the window:
[2024-10-02T19:10:45Z INFO iotasoft_ui::app] ui_size: [[0.0 0.0] - [1024.0 768.0]]
...
[2024-10-02T19:10:48Z INFO iotasoft_ui::app] ui_size: [[0.0 0.0] - [1024.0 768.0]]
...
[2024-10-02T19:10:49Z INFO iotasoft_ui::app] ui_size: [[0.0 0.0] - [1024.0 768.0]]
To Reproduce Steps to reproduce the behavior:
- Add the above code to an
eframe_template - Run
- Drag window
- Observe log
Expected behavior The reported origin is the actual origin, and changes when the window is moved, maximized, full-screened, restored, minimized, etc.
Screenshots
Desktop (please complete the following information):
- OS: Windows 11 Pro
- Browser: N/A
- Version:
egui,eframeare0.28.1
Smartphone (please complete the following information):
- Device: N/A
- OS: N/A
- Browser N/A
- Version: N/A
Additional context
Please see below.
let outer_rect = ui
.ctx()
.input(|i| i.viewport().outer_rect.unwrap_or(egui::Rect::ZERO));
let inner_rect = ui
.ctx()
.input(|i| i.viewport().inner_rect.unwrap_or(egui::Rect::ZERO));
Thanks for the workarounds!
This is still a discrepancy between the docs and implementation.