Click a status bar statistic to copy its value

This commit is contained in:
Dmussi committed 2026-10-25 23:24:26 -04:00
1 parent 42bbf6baa2
commit 848b0e658a
1 file changed
+11 -1
+11 -1
View File
@@ -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);
}
});