diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 47bc6dd4a7..0296b0dc47 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -263,7 +263,7 @@ PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)), EnableTextChangedEvents(false); #endif /* _WIN32 */ Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) { - auto selected_item = this->GetSelection(); + auto selected_item = evt.GetSelection(); auto marker = reinterpret_cast(this->GetClientData(selected_item)); if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) { @@ -383,9 +383,9 @@ void PresetComboBox::set_label_marker(int item, LabelItemType label_item_type) this->SetClientData(item, (void*)label_item_type); } -void PresetComboBox::check_selection() +void PresetComboBox::check_selection(int selection) { - this->last_selected = GetSelection(); + this->last_selected = selection; } void PresetComboBox::msw_rescale() @@ -3532,6 +3532,14 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt) auto preset_type = static_cast(evt.GetInt()); auto *combo = static_cast(evt.GetEventObject()); + // 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. + // So, use GetSelection() from event parameter + // But in this function we couldn't use evt.GetSelection(), because m_commandInt is used for preset_type + // Thus, get selection in this way: + int selection = combo->FindString(evt.GetString(), true); + auto idx = combo->get_extruder_idx(); //! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox, @@ -3542,7 +3550,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt) //! combo->GetStringSelection().ToUTF8().data()); const std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type, - Preset::remove_suffix_modified(combo->GetString(combo->GetSelection()).ToUTF8().data())); + Preset::remove_suffix_modified(combo->GetString(selection).ToUTF8().data())); if (preset_type == Preset::TYPE_FILAMENT) { wxGetApp().preset_bundle->set_filament_preset(idx, preset_name); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index fc6f839faa..601c044768 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -69,7 +69,7 @@ public: void set_extruder_idx(const int extr_idx) { extruder_idx = extr_idx; } int get_extruder_idx() const { return extruder_idx; } int em_unit() const { return m_em_unit; } - void check_selection(); + void check_selection(int selection); void msw_rescale(); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index a5d8b23958..3731f03de4 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -1254,7 +1254,7 @@ void PresetCollection::update_plater_ui(GUI::PresetComboBox *ui) ui->SetSelection(selected_preset_item); ui->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip); - ui->check_selection(); + ui->check_selection(selected_preset_item); ui->Thaw(); // Update control min size after rescale (changed Display DPI under MSW) diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp index 84003c9777..ba806a0b2d 100644 --- a/src/slic3r/GUI/PresetBundle.cpp +++ b/src/slic3r/GUI/PresetBundle.cpp @@ -1737,7 +1737,7 @@ void PresetBundle::update_plater_filament_ui(unsigned int idx_extruder, GUI::Pre ui->SetSelection(selected_preset_item); ui->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip); - ui->check_selection(); + ui->check_selection(selected_preset_item); ui->Thaw(); // Update control min size after rescale (changed Display DPI under MSW) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 78616adb9e..0c68979f19 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -230,7 +230,13 @@ void Tab::create_preset_tab() //! but the OSX version derived from wxOwnerDrawnCombo, instead of: //! select_preset(m_presets_choice->GetStringSelection().ToUTF8().data()); //! we doing next: - int selected_item = m_presets_choice->GetSelection(); + // int selected_item = m_presets_choice->GetSelection(); + + // 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. + // So, use GetSelection() from event parameter + int selected_item = e.GetSelection(); if (m_selected_preset_item == size_t(selected_item) && !m_presets->current_is_dirty()) return; if (selected_item >= 0) {