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

Fix broken mouse coordinates when there's padding on the canvas element (#4729)

* Closes https://github.com/emilk/egui/issues/4725

Also fixes touch input being wrong if the web page is scrolled.
This commit is contained in:
Emil Ernerfeldt
2024-06-28 13:02:36 +02:00
committed by GitHub
parent a6937f79f3
commit 254dfc1ebc
4 changed files with 38 additions and 16 deletions

View File

@@ -115,8 +115,8 @@ impl TextAgent {
let Some(ime) = ime else { return Ok(()) };
let ime_pos = ime.cursor_rect.left_top();
let canvas_rect = canvas.get_bounding_client_rect();
let new_pos = ime_pos + egui::vec2(canvas_rect.left() as f32, canvas_rect.top() as f32);
let canvas_rect = super::canvas_content_rect(canvas);
let new_pos = canvas_rect.min + ime_pos.to_vec2();
let style = self.input.style();
style.set_property("top", &format!("{}px", new_pos.y))?;