From 60d8a7b3011e6b0dce2300427e462f8a3c1ef84f Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 24 Sep 2021 10:53:11 +0200 Subject: [PATCH] MSW specific: Follow up https://github.com/prusa3d/PrusaSlicer/commit/683cb4245440fc8926e39bf4b24f42073ab43e35 - Set Selection for the content of focused controls (TextCtrls a SpinCtrls) --- src/slic3r/GUI/Tab.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 6b7044b0df..c91ac47843 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1188,11 +1188,21 @@ void Tab::activate_option(const std::string& opt_key, const wxString& category) break; } + auto set_focus = [](wxWindow* win) { + win->SetFocus(); +#ifdef WIN32 + if (wxTextCtrl* text = dynamic_cast(win)) + text->SetSelection(-1, -1); + else if (wxSpinCtrl* spin = dynamic_cast(win)) + spin->SetSelection(-1, -1); +#endif // WIN32 + }; + Field* field = get_field(opt_key); // focused selected field if (field) - field->getWindow()->SetFocus(); + set_focus(field->getWindow()); else if (category == "Single extruder MM setup") { // When we show and hide "Single extruder MM setup" page, // related options are still in the search list @@ -1200,7 +1210,7 @@ void Tab::activate_option(const std::string& opt_key, const wxString& category) // as a "way" to show hidden page again field = get_field("single_extruder_multi_material"); if (field) - field->getWindow()->SetFocus(); + set_focus(field->getWindow()); } m_highlighter.init(get_custom_ctrl_with_blinking_ptr(opt_key));