always set input and position when launching search_dialog

This commit is contained in:
themanyone 2024-07-14 07:07:01 -08:00 committed by Lukas Matena
parent e855ab5d46
commit bdc8cc07d4
4 changed files with 19 additions and 6 deletions

View File

@ -1538,7 +1538,10 @@ void MainFrame::init_menubar_as_editor()
editMenu->AppendSeparator(); editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _L("Searc&h") + "\tCtrl+F", append_menu_item(editMenu, wxID_ANY, _L("Searc&h") + "\tCtrl+F",
_L("Search in settings"), [](wxCommandEvent&) { wxGetApp().show_search_dialog(); }, _L("Search in settings"), [this](wxCommandEvent&) {
// wxGetApp().show_search_dialog();
m_tabpanel->GetTopBarItemsCtrl()->TriggerSearch();
},
"search", nullptr, []() {return true; }, this); "search", nullptr, []() {return true; }, this);
} }
@ -2267,7 +2270,8 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
#else /* __APPLE__ */ #else /* __APPLE__ */
case WXK_CONTROL_F: case WXK_CONTROL_F:
#endif /* __APPLE__ */ #endif /* __APPLE__ */
case 'F': { wxGetApp().show_search_dialog(); break; } case 'F': { m_tabpanel->GetTopBarItemsCtrl()->TriggerSearch();
break; }
default:break; default:break;
} }
} }

View File

@ -496,6 +496,7 @@ void OptionsSearcher::show_dialog(bool show /*= true*/)
search_dialog->Popup(); search_dialog->Popup();
if (!search_input->HasFocus()) if (!search_input->HasFocus())
search_input->SetFocus(); search_input->SetFocus();
wxYield();
} }
void OptionsSearcher::dlg_sys_color_changed() void OptionsSearcher::dlg_sys_color_changed()

View File

@ -261,8 +261,7 @@ void TopBarItemsCtrl::CreateSearch()
m_search->SetOnDropDownIcon([this]() m_search->SetOnDropDownIcon([this]()
{ {
wxGetApp().searcher().set_search_input(m_search); TriggerSearch();
wxGetApp().show_search_dialog();
}); });
m_search->Bind(wxEVT_KILL_FOCUS, [](wxFocusEvent& e) m_search->Bind(wxEVT_KILL_FOCUS, [](wxFocusEvent& e)
@ -286,8 +285,7 @@ void TopBarItemsCtrl::CreateSearch()
ctrl->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& event) ctrl->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& event)
{ {
wxGetApp().searcher().set_search_input(m_search); TriggerSearch();
wxGetApp().show_search_dialog();
event.Skip(); event.Skip();
}); });
@ -299,6 +297,15 @@ void TopBarItemsCtrl::CreateSearch()
}); });
} }
void TopBarItemsCtrl::TriggerSearch()
{
if (m_search && m_search->GetTextCtrl())
{
wxGetApp().searcher().set_search_input(m_search);
wxGetApp().show_search_dialog();
}
}
void TopBarItemsCtrl::UpdateSearchSizeAndPosition() void TopBarItemsCtrl::UpdateSearchSizeAndPosition()
{ {
if (!m_workspace_btn || !m_account_btn) if (!m_workspace_btn || !m_account_btn)

View File

@ -98,6 +98,7 @@ public:
void UnselectPopupButtons(); void UnselectPopupButtons();
void CreateSearch(); void CreateSearch();
void TriggerSearch();
void ShowFull(); void ShowFull();
void ShowJustMode(); void ShowJustMode();
void SetSettingsButtonTooltip(const wxString& tooltip); void SetSettingsButtonTooltip(const wxString& tooltip);