TopBar: Search: Fixed OSX issue with Layout on Show()

This commit is contained in:
YuSanka 2024-01-18 16:45:21 +01:00 committed by David Kocik
parent 2309b66e02
commit ce91ef8f49
2 changed files with 18 additions and 8 deletions

View File

@ -512,11 +512,12 @@ void OptionsSearcher::set_search_input(TextInput* input_ctrl)
ctrl->Bind(wxEVT_KEY_DOWN, [this](wxKeyEvent& e) ctrl->Bind(wxEVT_KEY_DOWN, [this](wxKeyEvent& e)
{ {
if (e.GetKeyCode() == WXK_TAB) int key = e.GetKeyCode();
if (key == WXK_TAB)
search_input->Navigate(e.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward); search_input->Navigate(e.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward);
else if (e.GetKeyCode() == WXK_ESCAPE) else if (key == WXK_ESCAPE)
search_dialog->EndModal(wxID_CLOSE); search_dialog->EndModal(wxID_CLOSE);
else if (search_dialog) else if (search_dialog && (key == WXK_UP || key == WXK_DOWN || key == WXK_NUMPAD_ENTER || key == WXK_RETURN))
search_dialog->KeyDown(e); search_dialog->KeyDown(e);
e.Skip(); e.Skip();
}); });
@ -528,6 +529,11 @@ void OptionsSearcher::set_search_input(TextInput* input_ctrl)
event.Skip(); event.Skip();
}); });
ctrl->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& event) {
GUI::wxGetApp().show_search_dialog();
event.Skip();
});
search_input->Bind(wxEVT_MOVE, [this](wxMoveEvent& event) search_input->Bind(wxEVT_MOVE, [this](wxMoveEvent& event)
{ {
event.Skip(); event.Skip();
@ -637,7 +643,7 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher, wxWindow* parent)
check_english ->Bind(wxEVT_CHECKBOX, &SearchDialog::OnCheck, this); check_english ->Bind(wxEVT_CHECKBOX, &SearchDialog::OnCheck, this);
// Bind(wxEVT_MOTION, &SearchDialog::OnMotion, this); // Bind(wxEVT_MOTION, &SearchDialog::OnMotion, this);
Bind(wxEVT_LEFT_DOWN, &SearchDialog::OnLeftDown, this); // Bind(wxEVT_LEFT_DOWN, &SearchDialog::OnLeftDown, this);
SetSizer(topSizer); SetSizer(topSizer);
topSizer->SetSizeHints(this); topSizer->SetSizeHints(this);
@ -660,7 +666,11 @@ void SearchDialog::Popup(wxPoint position /*= wxDefaultPosition*/)
if (position != wxDefaultPosition) if (position != wxDefaultPosition)
this->SetPosition(position); this->SetPosition(position);
#ifdef __APPLE__
this->ShowWithoutActivating();
#else
this->Show(); this->Show();
#endif
} }
void SearchDialog::ProcessSelection(wxDataViewItem selection) void SearchDialog::ProcessSelection(wxDataViewItem selection)

View File

@ -1148,14 +1148,14 @@ void Tab::activate_option(const std::string& opt_key, const wxString& category)
{ {
wxString page_title = translate_category(category, m_type); wxString page_title = translate_category(category, m_type);
auto cur_item = m_treectrl->GetFirstVisibleItem();
if (!cur_item)
return;
// We should to activate a tab with searched option, if it doesn't. // We should to activate a tab with searched option, if it doesn't.
// And do it before finding of the cur_item to avoid a case when Tab isn't activated jet and all treeItems are invisible // And do it before finding of the cur_item to avoid a case when Tab isn't activated jet and all treeItems are invisible
wxGetApp().mainframe->select_tab(this); wxGetApp().mainframe->select_tab(this);
auto cur_item = m_treectrl->GetFirstVisibleItem();
if (!cur_item)
return;
while (cur_item) { while (cur_item) {
auto title = m_treectrl->GetItemText(cur_item); auto title = m_treectrl->GetItemText(cur_item);
if (page_title != title) { if (page_title != title) {