Skip to content

Commit

Permalink
Merge pull request #65 from nwg-piotr/select_single
Browse files Browse the repository at this point in the history
auto-select 1st line in search results #56
  • Loading branch information
nwg-piotr authored Jul 14, 2020
2 parents c019f90 + 7f6fc8a commit c9deb5a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dmenu/dmenu_classes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ bool DMenu::on_key_press_event(GdkEventKey* key_event) {
this -> searchbox.set_text(this -> search_phrase);
this -> filter_view();
return true;
} else if (key_event -> keyval == GDK_KEY_Return) {
// Workaround to launch the single item which has been selected programmatically
this -> get_children()[1] -> activate();
return true;
} else if (key_event -> keyval == GDK_KEY_Insert) {
this -> search_phrase = "";
case_sensitive = !case_sensitive;
Expand Down Expand Up @@ -157,6 +161,11 @@ void DMenu::filter_view() {
item -> signal_activate().connect(sigc::bind<Glib::ustring>(sigc::mem_fun
(*this, &DMenu::on_item_clicked), command));
this -> append(*item);
// This will highlight 1st menu item, still it won't start on Enter.
// See workaround in on_key_press_event.
if (cnt == 0) {
item -> select();
}
cnt++;
if (cnt > rows - 1) {
limit_exhausted = true;
Expand Down

0 comments on commit c9deb5a

Please sign in to comment.