From 47f3d8226571e523edaaccba6d07748eb7270e17 Mon Sep 17 00:00:00 2001 From: Piyush Mishra Date: Wed, 28 Apr 2021 09:23:22 +0530 Subject: [PATCH] fix keys --- src/lib.rs | 15 +++++++++++---- ui.glade | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e6986d7..233977a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -227,10 +227,17 @@ pub fn build_ui(app: >k::Application, config: &Arc) { log_area.get_buffer().expect("Couldn't get window").set_text(""); None })), - "send_entry_activate" => Box::new(clone!(@weak config, @weak bar => @default-return None, move |a| { - let ent = a[0].get::().unwrap().unwrap(); - putil::send_text(&config, &ent, &bar); - None + "send_entry_key_press_event" => Box::new(clone!(@weak config, @weak bar => @default-return None, move |a| { + let ev = a[1].get::().unwrap().unwrap(); + if let Some(val) = ev.get_keyval() { + if let Some(val) = gdk::keys::keyval_name(val) { + if val == "Return" { + let ent = a[0].get::().unwrap().unwrap(); + putil::send_text(&config, &ent, &bar); + } + } + } + Some(false.to_value()) })), "send_btn_clicked" => Box::new(clone!(@weak config, @weak bar, @weak send_entry => @default-return None, move |_| { putil::send_text(&config, &send_entry, &bar); diff --git a/ui.glade b/ui.glade index 9bec4cf..19daae7 100644 --- a/ui.glade +++ b/ui.glade @@ -663,7 +663,7 @@ True True - + True