diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 9e7409c11..a71fb1448 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1920,6 +1920,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) sidebar->Bind(wxEVT_COMBOBOX, &priv::on_select_preset, this); sidebar->Bind(EVT_OBJ_LIST_OBJECT_SELECT, [this](wxEvent&) { priv::selection_changed(); }); sidebar->Bind(EVT_SCHEDULE_BACKGROUND_PROCESS, [this](SimpleEvent&) { this->schedule_background_process(); }); + // jump to found option from SearchDialog + q->Bind(wxCUSTOMEVT_JUMP_TO_OPTION, [this](wxCommandEvent& evt) { sidebar->jump_to_option(evt.GetInt()); }); } wxGLCanvas* view3D_canvas = view3D->get_wxglcanvas(); diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 000ebf402..1e37dc372 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -24,6 +24,8 @@ using boost::optional; namespace Slic3r { +wxDEFINE_EVENT(wxCUSTOMEVT_JUMP_TO_OPTION, wxCommandEvent); + using GUI::from_u8; using GUI::into_u8; @@ -293,8 +295,6 @@ OptionsSearcher::OptionsSearcher() OptionsSearcher::~OptionsSearcher() { - if (search_dialog) - search_dialog->Destroy(); } void OptionsSearcher::init(std::vector<InputInfo> input_values) @@ -530,9 +530,16 @@ void SearchDialog::ProcessSelection(wxDataViewItem selection) { if (!selection.IsOk()) return; - - GUI::wxGetApp().sidebar().jump_to_option(search_list_model->GetRow(selection)); this->EndModal(wxID_CLOSE); + + // If call GUI::wxGetApp().sidebar.jump_to_option() directly from here, + // then mainframe will not have focus and found option will not be "active" (have cursor) as a result + // SearchDialog have to be closed and have to lose a focus + // and only after that jump_to_option() function can be called + // So, post event to plater: + wxCommandEvent event(wxCUSTOMEVT_JUMP_TO_OPTION); + event.SetInt(search_list_model->GetRow(selection)); + wxPostEvent(GUI::wxGetApp().plater(), event); } void SearchDialog::OnInputText(wxCommandEvent&) diff --git a/src/slic3r/GUI/Search.hpp b/src/slic3r/GUI/Search.hpp index 99575e1fa..19de58f96 100644 --- a/src/slic3r/GUI/Search.hpp +++ b/src/slic3r/GUI/Search.hpp @@ -22,6 +22,8 @@ namespace Slic3r { +wxDECLARE_EVENT(wxCUSTOMEVT_JUMP_TO_OPTION, wxCommandEvent); + namespace Search{ class SearchDialog;