From b15344d78301026869705e60b394b4d0349a135c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 19 Jul 2024 16:22:38 +0200 Subject: [PATCH] SearchDialog: Fixed hide of the dialog, when some item in list is selected --- src/slic3r/GUI/Search.cpp | 18 ++++++++++++++---- src/slic3r/GUI/TopBar.hpp | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index d16e784c1b..a7c152f2ba 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -455,6 +455,12 @@ void OptionsSearcher::update_dialog_position() void OptionsSearcher::check_and_hide_dialog() { +#ifdef __linux__ + // Temporary linux specific workaround: + // has_focus(search_dialog) always returns false + // That's why search dialog will be hidden whole the time + return; +#endif if (search_dialog && search_dialog->IsShown() && !has_focus(search_dialog)) show_dialog(false); } @@ -468,7 +474,7 @@ void OptionsSearcher::set_focus_to_parent() void OptionsSearcher::show_dialog(bool show /*= true*/) { if (search_dialog && !show) { - search_dialog->EndModal(wxID_CLOSE); + search_dialog->Hide(); return; } @@ -522,9 +528,13 @@ void OptionsSearcher::process_key_down_from_input(wxKeyEvent& e) { int key = e.GetKeyCode(); if (key == WXK_ESCAPE) - search_dialog->EndModal(wxID_CLOSE); - else if (search_dialog && (key == WXK_UP || key == WXK_DOWN || key == WXK_NUMPAD_ENTER || key == WXK_RETURN)) + search_dialog->Hide(); + else if (search_dialog && (key == WXK_UP || key == WXK_DOWN || key == WXK_NUMPAD_ENTER || key == WXK_RETURN)) { search_dialog->KeyDown(e); +#ifdef __linux__ + search_dialog->SetFocus(); +#endif // __linux__ + } } void OptionsSearcher::set_search_input(TextInput* input_ctrl) @@ -667,7 +677,7 @@ void SearchDialog::ProcessSelection(wxDataViewItem selection) { if (!selection.IsOk()) return; - this->EndModal(wxID_CLOSE); + this->Hide(); // 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 diff --git a/src/slic3r/GUI/TopBar.hpp b/src/slic3r/GUI/TopBar.hpp index 1c01d18c3c..60c40a39ef 100644 --- a/src/slic3r/GUI/TopBar.hpp +++ b/src/slic3r/GUI/TopBar.hpp @@ -2,7 +2,7 @@ #define slic3r_TopBar_hpp_ #include -#include "wxExtensions.hpp" +#include #include "Widgets/TextInput.hpp" class TopBarMenus;