From ce91ef8f49528d791ce6a8bd577371dbaad79f71 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 18 Jan 2024 16:45:21 +0100 Subject: [PATCH] TopBar: Search: Fixed OSX issue with Layout on Show() --- src/slic3r/GUI/Search.cpp | 18 ++++++++++++++---- src/slic3r/GUI/Tab.cpp | 8 ++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index e54e0430a4..a35388a88a 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -512,11 +512,12 @@ void OptionsSearcher::set_search_input(TextInput* input_ctrl) 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); - else if (e.GetKeyCode() == WXK_ESCAPE) + else if (key == WXK_ESCAPE) 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); e.Skip(); }); @@ -528,6 +529,11 @@ void OptionsSearcher::set_search_input(TextInput* input_ctrl) event.Skip(); }); + ctrl->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& event) { + GUI::wxGetApp().show_search_dialog(); + event.Skip(); + }); + search_input->Bind(wxEVT_MOVE, [this](wxMoveEvent& event) { event.Skip(); @@ -637,7 +643,7 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher, wxWindow* parent) check_english ->Bind(wxEVT_CHECKBOX, &SearchDialog::OnCheck, this); // Bind(wxEVT_MOTION, &SearchDialog::OnMotion, this); - Bind(wxEVT_LEFT_DOWN, &SearchDialog::OnLeftDown, this); +// Bind(wxEVT_LEFT_DOWN, &SearchDialog::OnLeftDown, this); SetSizer(topSizer); topSizer->SetSizeHints(this); @@ -660,7 +666,11 @@ void SearchDialog::Popup(wxPoint position /*= wxDefaultPosition*/) if (position != wxDefaultPosition) this->SetPosition(position); +#ifdef __APPLE__ + this->ShowWithoutActivating(); +#else this->Show(); +#endif } void SearchDialog::ProcessSelection(wxDataViewItem selection) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index eacc6d8361..11bea55b24 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1148,14 +1148,14 @@ void Tab::activate_option(const std::string& opt_key, const wxString& category) { 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. // 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); + auto cur_item = m_treectrl->GetFirstVisibleItem(); + if (!cur_item) + return; + while (cur_item) { auto title = m_treectrl->GetItemText(cur_item); if (page_title != title) {