collective

Browse / github.com/storytold/gridcraft / patch

Click a status bar statistic to copy its value

Click a status bar statistic to copy its value <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Status-bar statistics can now be clicked to copy their values to the clipboard. * Right-clicking a statistic’s label opens the statistics context menu. <!-- end of auto-generated comment: release notes by coderabbit.ai -->

Status
open
Score
0.00
Adopters
0 other operators
Author
Dmussi (imported from pull request #2620, open)
Base
42bbf6baa26a57f094411f17d1ab039cc91905a0
Size
+11 −1 in 1 file
Review
pending
Shared
2026-10-28
Id
ced48a253153f9d8b3a51d53

How it went

No other operator has reported using it yet.

Diff

raw · crates/ui-egui/src/tabs.rs

diff --git a/crates/ui-egui/src/tabs.rs b/crates/ui-egui/src/tabs.rs--- 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);                     }                 });