From 848b0e658a3bf622abae0c724fbba0358facd751 Mon Sep 17 00:00:00 2001 From: Dmussi Date: Sun, 25 Oct 2026 23:24:26 -0400 Subject: [PATCH] Click a status bar statistic to copy its value --- crates/ui-egui/src/tabs.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/tabs.rs b/crates/ui-egui/src/tabs.rs index b2216ca93..79278a539 100644 --- a/crates/ui-egui/src/tabs.rs +++ b/crates/ui-egui/src/tabs.rs @@ -412,8 +412,18 @@ pub fn status_bar(app: &mut SheetApp, ui: &mut Ui) { } ui.add_space(16.0); // The layout runs right to left, so the last statistic is drawn first. + // Clicking a statistic copies its value (without the label) to the clipboard. for p in selection_statistics(app).into_iter().rev() { - text(ui, egui::RichText::new(p).font(theme::ui_font(12.5)).color(t.text_dim)); + let value = p.split_once(": ").map_or(p.as_str(), |(_, v)| v).to_owned(); + let resp = ui.add( + egui::Label::new(egui::RichText::new(p).font(theme::ui_font(12.5)).color(t.text_dim)).selectable(false).sense(Sense::click()), + ); + let resp = resp.on_hover_cursor(egui::CursorIcon::PointingHand).on_hover_text("Click to copy"); + if resp.clicked() { + ui.ctx().copy_text(value); + } + // The label senses clicks, so it also has to open the statistics menu on right-click. + resp.context_menu(|ui| status_bar_menu(app, ui)); ui.add_space(10.0); } });