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();
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);
}
@ -2267,7 +2270,8 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
#else /* __APPLE__ */
case WXK_CONTROL_F:
#endif /* __APPLE__ */
case 'F': { wxGetApp().show_search_dialog(); break; }
case 'F': { m_tabpanel->GetTopBarItemsCtrl()->TriggerSearch();
break; }
default:break;
}
}

View File

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

View File

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

View File

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