From f3250976112d669b11c6f43f2cd40a84ba1d893c Mon Sep 17 00:00:00 2001 From: Matt Keeter Date: Fri, 27 Mar 2026 06:18:52 -0400 Subject: [PATCH] Only apply cursor style to the (#8036) This improves cases where the canvas does not cover the full screen, which was a goal in [release 0.28.0](https://github.com/emilk/egui/releases/tag/0.28.0). * Closes * [X] I have followed the instructions in the PR template --- crates/eframe/src/web/app_runner.rs | 2 +- crates/eframe/src/web/mod.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index b90b8a5e1..7161a665e 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -393,7 +393,7 @@ impl AppRunner { } } - super::set_cursor_icon(cursor_icon); + super::set_cursor_icon(self.canvas(), cursor_icon); if self.has_focus() { // The eframe app has focus. diff --git a/crates/eframe/src/web/mod.rs b/crates/eframe/src/web/mod.rs index 87771f722..dc743ec49 100644 --- a/crates/eframe/src/web/mod.rs +++ b/crates/eframe/src/web/mod.rs @@ -178,10 +178,8 @@ fn canvas_size_in_points(canvas: &web_sys::HtmlCanvasElement, ctx: &egui::Contex // ---------------------------------------------------------------------------- /// Set the cursor icon. -fn set_cursor_icon(cursor: egui::CursorIcon) -> Option<()> { - let document = web_sys::window()?.document()?; - document - .body()? +fn set_cursor_icon(canvas: &web_sys::HtmlCanvasElement, cursor: egui::CursorIcon) -> Option<()> { + canvas .style() .set_property("cursor", cursor_web_name(cursor)) .ok()