From 55ccaa3bf4c1d668b4604ecda41c7174289e8488 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 01:03:54 +0000 Subject: [PATCH] FlyoutButton's face wears the button's selected state from its resolved props: the Common it read is taken at step 1 --- crates/ui-panels/src/rails/flyout.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ui-panels/src/rails/flyout.rs b/crates/ui-panels/src/rails/flyout.rs index 4843bcbfe..50f4c05ab 100644 --- a/crates/ui-panels/src/rails/flyout.rs +++ b/crates/ui-panels/src/rails/flyout.rs @@ -148,15 +148,15 @@ impl<'a, T: Value + 'static> FlyoutButton<'a, T> { } /// The face the button shows: the shown tool's icon, in the look of its command (label, enabled state, marked dot). - /// The button itself runs the command, so the face only wears it. - fn face(&self, laid: &Laid) -> IconButton<'static> { + /// The button itself runs the command, so the face only wears it, and the button's selected state with it. + fn face(&self, laid: &Laid, selected: bool) -> IconButton<'static> { let resolved = laid.resolved.get(laid.shown).and_then(Option::as_ref); let icon = resolved.and_then(|resolved| resolved.icon.clone()).map_or_else(|| IconId::new("more"), IconId::from); let face = match self.tools.get(laid.shown) { Some(tool) => IconButton::command(icon, tool.command.clone()), None => IconButton::new(icon), }; - let mut face = face.selected(self.common.selected.unwrap_or(false)); + let mut face = face.selected(selected); if self.has_flyout() { face = face.popup(PopupKind::Menu); } @@ -181,7 +181,7 @@ impl Component for FlyoutButton<'_, T> { fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { let laid = self.resolve(cx); - cx.face(self.face(&laid)) + cx.face(self.face(&laid, cx.resolved.selected == Some(true))) } fn sense(&self) -> Sense { @@ -304,9 +304,9 @@ impl Component for FlyoutButton<'_, T> { } } - fn paint(&mut self, ui: &mut PaintUi<'_>, _: &Cx<'_, Self>) { + fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { let Some(laid) = &self.laid else { return }; - let face = self.face(laid); + let face = self.face(laid, cx.resolved.selected == Some(true)); ui.face(FACE, face); }