Skip to content

Commit 3fa97db

Browse files
committed
feat: change tooltip to click-to-show popover
Changed info icon behavior from hover tooltip to click-to-show popover for better UX on touch devices and intentional interaction.
1 parent 690e298 commit 3fa97db

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/ui/tab_builder.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::models::Keybind;
22
use crate::ui::widgets::{create_keycap, get_modifier_display};
33
use gtk4::prelude::*;
44
use gtk4::{
5-
Box as GtkBox, FlowBox, FlowBoxChild, Label, Orientation, ScrolledWindow, SearchEntry,
6-
SelectionMode,
5+
Box as GtkBox, Button, FlowBox, FlowBoxChild, Label, Orientation, Popover, ScrolledWindow,
6+
SearchEntry, SelectionMode,
77
};
88

99
/// Creates a tab page with keybinds table and search
@@ -72,21 +72,40 @@ pub fn create_tab_page(binds: Vec<Keybind>) -> (GtkBox, SearchEntry, ScrolledWin
7272
};
7373

7474
keys_box.append(&create_keycap(&key_display, false));
75-
75+
7676
main_row.append(&keys_box);
7777

7878
// Spacer to push info icon to the right
7979
let spacer = GtkBox::new(Orientation::Horizontal, 0);
8080
spacer.set_hexpand(true);
8181
main_row.append(&spacer);
8282

83-
// Info icon on the right (same level as keys)
83+
// Info icon on the right (same level as keys) - now clickable
8484
if let Some(desc) = &bind.description {
8585
let info_icon = Label::new(Some("🛈"));
86-
info_icon.set_tooltip_text(Some(desc));
8786
info_icon.add_css_class("info-icon");
8887
info_icon.set_halign(gtk4::Align::End);
8988
info_icon.set_valign(gtk4::Align::Center);
89+
90+
// Create popover with description
91+
let popover = Popover::new();
92+
let desc_label = Label::new(Some(desc));
93+
desc_label.set_wrap(true);
94+
desc_label.set_max_width_chars(40);
95+
desc_label.set_margin_start(12);
96+
desc_label.set_margin_end(12);
97+
desc_label.set_margin_top(8);
98+
desc_label.set_margin_bottom(8);
99+
popover.set_child(Some(&desc_label));
100+
popover.set_parent(&info_icon);
101+
102+
// Add click gesture to label
103+
let gesture = gtk4::GestureClick::new();
104+
gesture.connect_released(move |_, _, _, _| {
105+
popover.popup();
106+
});
107+
info_icon.add_controller(gesture);
108+
90109
main_row.append(&info_icon);
91110
}
92111

0 commit comments

Comments
 (0)