Skip to content

Commit

Permalink
fix keys
Browse files Browse the repository at this point in the history
  • Loading branch information
PiyushXCoder committed Apr 28, 2021
1 parent 9fd576e commit 47f3d82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ui.glade
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 47f3d82

Please sign in to comment.