remove Escape accels from window actions as blocking dialog windows, replace it with local EventControllerKey implementation, that depends of active focus

This commit is contained in:
yggverse 2025-03-20 23:55:33 +02:00
parent 4a81297ef1
commit d469499d46
10 changed files with 37 additions and 68 deletions

View file

@ -49,6 +49,22 @@ impl Search {
g_box.append(&placeholder.label);
g_box.append(&close);
// Hide widget on `Escape` key pressed
g_box.add_controller({
use gtk::{gdk::Key, glib::Propagation};
let c = gtk::EventControllerKey::new();
c.connect_key_pressed({
let g_box = g_box.clone();
move |_, k, _, _| {
if k == Key::Escape {
g_box.set_visible(false)
}
Propagation::Stop
}
});
c
});
// Connect events
close.connect_clicked({
let form = form.clone();