This commit is contained in:
Piyush मिश्रः 2021-04-28 09:23:22 +05:30
parent 9fd576e48c
commit 47f3d82265
2 changed files with 12 additions and 5 deletions

View File

@ -227,10 +227,17 @@ pub fn build_ui(app: &gtk::Application, config: &Arc<Config>) {
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::<gtk::Entry>().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::<gdk::Event>().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::<gtk::Entry>().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);

View File

@ -663,7 +663,7 @@
<object class="GtkEntry" id="send_entry">
<property name="visible">True</property>
<property name="can-focus">True</property>
<signal name="activate" handler="send_entry_activate" swapped="no"/>
<signal name="key-press-event" handler="send_entry_key_press_event" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>