Skip to content

Commit f325097

Browse files
authored
Only apply cursor style to the <canvas> (#8036)
<!-- Please read the "Making a PR" section of [`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/main/CONTRIBUTING.md) before opening a Pull Request! * Keep your PR:s small and focused. * The PR title is what ends up in the changelog, so make it descriptive! * If applicable, add a screenshot or gif. * If it is a non-trivial addition, consider adding a demo for it to `egui_demo_lib`, or a new example. * Do NOT open PR:s from your `master` branch, as that makes it hard for maintainers to test and add commits to your PR. * Remember to run `cargo fmt` and `cargo clippy`. * Open the PR as a draft until you have self-reviewed it and run `./scripts/check.sh`. * When you have addressed a PR comment, mark it as resolved. Please be patient! I will review your PR, but my time is limited! --> 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 <#8035> * [X] I have followed the instructions in the PR template
1 parent 3cf3141 commit f325097

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

crates/eframe/src/web/app_runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl AppRunner {
393393
}
394394
}
395395

396-
super::set_cursor_icon(cursor_icon);
396+
super::set_cursor_icon(self.canvas(), cursor_icon);
397397

398398
if self.has_focus() {
399399
// The eframe app has focus.

crates/eframe/src/web/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,8 @@ fn canvas_size_in_points(canvas: &web_sys::HtmlCanvasElement, ctx: &egui::Contex
178178
// ----------------------------------------------------------------------------
179179

180180
/// Set the cursor icon.
181-
fn set_cursor_icon(cursor: egui::CursorIcon) -> Option<()> {
182-
let document = web_sys::window()?.document()?;
183-
document
184-
.body()?
181+
fn set_cursor_icon(canvas: &web_sys::HtmlCanvasElement, cursor: egui::CursorIcon) -> Option<()> {
182+
canvas
185183
.style()
186184
.set_property("cursor", cursor_web_name(cursor))
187185
.ok()

0 commit comments

Comments
 (0)