Skip to content

Commit

Permalink
Fix search bar losing focus while typing (PR #13691 by @themanyone)
Browse files Browse the repository at this point in the history
  • Loading branch information
themanyone authored and lukasmatena committed Dec 13, 2024
1 parent 3db367b commit 209d23e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,6 @@ void MainFrame::init_menubar_as_editor()
editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _L("Searc&h") + "\tCtrl+F",
_L("Search in settings"), [this](wxCommandEvent&) {
// wxGetApp().show_search_dialog();
m_tabpanel->GetTopBarItemsCtrl()->TriggerSearch();
},
"search", nullptr, []() {return true; }, this);
Expand Down
9 changes: 4 additions & 5 deletions src/slic3r/GUI/Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,12 @@ void OptionsSearcher::edit_search_input()
void OptionsSearcher::process_key_down_from_input(wxKeyEvent& e)
{
int key = e.GetKeyCode();
if (key == WXK_ESCAPE)
if (key == WXK_ESCAPE) {
set_focus_to_parent();
search_dialog->Hide();
}
else if (search_dialog && (key == WXK_UP || key == WXK_DOWN || key == WXK_NUMPAD_ENTER || key == WXK_RETURN)) {
search_dialog->KeyDown(e);
#ifdef __linux__
search_dialog->SetFocus();
#endif // __linux__
}
}

Expand Down Expand Up @@ -708,7 +707,7 @@ void SearchDialog::OnKeyDown(wxKeyEvent& event)
if (key == WXK_UP || key == WXK_DOWN)
{
// So, for the next correct navigation, set focus on the search_list
// search_list->SetFocus(); // #ys_delete_after_test -> Looks like no need anymore
search_list->SetFocus();

auto item = search_list->GetSelection();

Expand Down
4 changes: 3 additions & 1 deletion src/slic3r/GUI/TopBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ void TopBarItemsCtrl::CreateSearch()

m_search->Bind(wxEVT_KILL_FOCUS, [](wxFocusEvent& e)
{
e.Skip();
wxGetApp().searcher().check_and_hide_dialog();
e.Skip();
});

wxTextCtrl* ctrl = m_search->GetTextCtrl();
Expand Down Expand Up @@ -303,6 +303,8 @@ void TopBarItemsCtrl::TriggerSearch()
{
wxGetApp().searcher().set_search_input(m_search);
wxGetApp().show_search_dialog();
wxTextCtrl* ctrl = m_search->GetTextCtrl();
ctrl->SetFocus(); // set focus back to search bar for typing
}
}

Expand Down

0 comments on commit 209d23e

Please sign in to comment.