Fix for #5231. Suppress scrolling for the PresetComboBoxes when they aren't dropped.

This commit is contained in:
YuSanka 2020-11-24 15:04:47 +01:00
parent 1ce8cddbda
commit 250bd689f2
2 changed files with 17 additions and 0 deletions

View File

@ -103,6 +103,8 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
// parameters for an icon's drawing
fill_width_height();
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent& evt) { m_suppress_change = false; });
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent& evt) { m_suppress_change = true ; });
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
@ -147,6 +149,15 @@ bool PresetComboBox::set_printer_technology(PrinterTechnology pt)
return false;
}
bool PresetComboBox::check_event_for_suppress_change(wxCommandEvent& evt)
{
if (m_suppress_change) {
evt.StopPropagation();
SetSelection(m_last_selected);
}
return m_suppress_change;
}
void PresetComboBox::invalidate_selection()
{
m_last_selected = INT_MAX; // this value means that no one item is selected
@ -534,6 +545,8 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
PresetComboBox(parent, preset_type, wxSize(15 * wxGetApp().em_unit(), -1))
{
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
if (check_event_for_suppress_change(evt))
return;
auto selected_item = evt.GetSelection();
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
@ -871,6 +884,8 @@ TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type)
PresetComboBox(parent, preset_type, wxSize(35 * wxGetApp().em_unit(), -1))
{
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
if (check_event_for_suppress_change(evt))
return;
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
// Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender")
// m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive.

View File

@ -86,6 +86,7 @@ protected:
int m_last_selected;
int m_em_unit;
bool m_suppress_change { true };
// parameters for an icon's drawing
int icon_height;
@ -98,6 +99,7 @@ protected:
PrinterTechnology printer_technology {ptAny};
bool check_event_for_suppress_change(wxCommandEvent& evt);
void invalidate_selection();
void validate_selection(bool predicate = false);
void update_selection();