Skip to content

Commit c9deb5a

Browse files
authored
Merge pull request #65 from nwg-piotr/select_single
auto-select 1st line in search results #56
2 parents c019f90 + 7f6fc8a commit c9deb5a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

dmenu/dmenu_classes.cc

+9
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ bool DMenu::on_key_press_event(GdkEventKey* key_event) {
106106
this -> searchbox.set_text(this -> search_phrase);
107107
this -> filter_view();
108108
return true;
109+
} else if (key_event -> keyval == GDK_KEY_Return) {
110+
// Workaround to launch the single item which has been selected programmatically
111+
this -> get_children()[1] -> activate();
112+
return true;
109113
} else if (key_event -> keyval == GDK_KEY_Insert) {
110114
this -> search_phrase = "";
111115
case_sensitive = !case_sensitive;
@@ -157,6 +161,11 @@ void DMenu::filter_view() {
157161
item -> signal_activate().connect(sigc::bind<Glib::ustring>(sigc::mem_fun
158162
(*this, &DMenu::on_item_clicked), command));
159163
this -> append(*item);
164+
// This will highlight 1st menu item, still it won't start on Enter.
165+
// See workaround in on_key_press_event.
166+
if (cnt == 0) {
167+
item -> select();
168+
}
160169
cnt++;
161170
if (cnt > rows - 1) {
162171
limit_exhausted = true;

0 commit comments

Comments
 (0)