Fix for #6941 - Search Settings: Put focus into input field when navigating to the setting

This commit is contained in:
YuSanka 2021-09-23 12:21:56 +02:00
parent d7216b5d68
commit 683cb42454
3 changed files with 15 additions and 4 deletions

View file

@ -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();

View file

@ -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&)

View file

@ -22,6 +22,8 @@
namespace Slic3r {
wxDECLARE_EVENT(wxCUSTOMEVT_JUMP_TO_OPTION, wxCommandEvent);
namespace Search{
class SearchDialog;