From 02ff040b74cef45876fb8cc7534474351a48a8d6 Mon Sep 17 00:00:00 2001 From: eason <85663565+mango766@users.noreply.github.com> Date: Wed, 25 Mar 2026 21:48:22 +0800 Subject: [PATCH] Fix: `Visuals::interact_cursor` support in `Button` (#7986) Closes #7947 ## Problem `Visuals::interact_cursor` stopped working for buttons after the `AtomLayout` refactor in commit 6eb7bb6e. Setting `interact_cursor` to e.g. `CursorIcon::PointingHand` no longer changes the cursor when hovering over a `Button`. ## Root Cause When `Button` was rewritten to use `AtomLayout` in #5830, the cursor-override block at the end of the old `Button::ui` was not carried over to the new `Button::atom_ui` method. The old code had: ```rust if let Some(cursor) = ui.visuals().interact_cursor { if response.hovered() { ui.ctx().set_cursor_icon(cursor); } } ``` This was the only place `interact_cursor` was checked, so the setting became entirely non-functional. ## Fix Re-add the same `interact_cursor` check in `Button::atom_ui`, right after painting and before `widget_info`, matching the original behavior. --------- Co-authored-by: easonysliu Co-authored-by: Emil Ernerfeldt --- crates/egui/src/widgets/button.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 7d9dddf0d..8ef047002 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -371,6 +371,12 @@ impl<'a> Button<'a> { AtomLayoutResponse::empty(prepared.response) }; + if let Some(cursor) = ui.visuals().interact_cursor + && response.response.hovered() + { + ui.ctx().set_cursor_icon(cursor); + } + response.response.widget_info(|| { if let Some(text) = &text { WidgetInfo::labeled(WidgetType::Button, ui.is_enabled(), text)