diff --git a/crates/voelin-gpui/src/shell/widgets.rs b/crates/voelin-gpui/src/shell/widgets.rs index e1ade04..572b2fe 100644 --- a/crates/voelin-gpui/src/shell/widgets.rs +++ b/crates/voelin-gpui/src/shell/widgets.rs @@ -232,7 +232,7 @@ type Handler = Box; /// A button that is an icon: 36 pixels (or `size`) square, round or with /// rounded corners, with a tooltip. Without a handler or disabled it draws -/// dimmed and does nothing. +/// dimmed and does nothing, and keeps its tooltip. #[derive(IntoElement)] pub struct IconButton { id: ElementId, @@ -354,14 +354,15 @@ impl RenderOnce for IconButton { if self.filled { button = button.border_1().border_color(hsla(ink)); } + // The tooltip is there while the button is off too: it says why (the voice + // page's stage button in a window too short for the larger stage). + button = button.tooltip(move |window, cx| { + gpui_kit::component::tooltip::Tooltip::new(label.clone()).build(window, cx) + }); if !self.enabled { return button.opacity(0.4).into_any_element(); } - button = button.cursor_pointer().hover(move |style| style.bg(hsla(hover))).tooltip( - move |window, cx| { - gpui_kit::component::tooltip::Tooltip::new(label.clone()).build(window, cx) - }, - ); + button = button.cursor_pointer().hover(move |style| style.bg(hsla(hover))); match self.on_click { Some(handler) => button.on_click(move |event, window, cx| handler(event, window, cx)), None => button,