Fix of #3889
This commit is contained in:
parent
d5bcddeed3
commit
5215b2ecb2
5 changed files with 22 additions and 8 deletions
|
@ -268,7 +268,7 @@ PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)),
|
||||||
EnableTextChangedEvents(false);
|
EnableTextChangedEvents(false);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
|
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
|
||||||
auto selected_item = this->GetSelection();
|
auto selected_item = evt.GetSelection();
|
||||||
|
|
||||||
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
||||||
if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) {
|
if (marker >= LABEL_ITEM_MARKER && marker < LABEL_ITEM_MAX) {
|
||||||
|
@ -388,9 +388,9 @@ void PresetComboBox::set_label_marker(int item, LabelItemType label_item_type)
|
||||||
this->SetClientData(item, (void*)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()
|
void PresetComboBox::msw_rescale()
|
||||||
|
@ -3627,6 +3627,14 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||||
auto preset_type = static_cast<Preset::Type>(evt.GetInt());
|
auto preset_type = static_cast<Preset::Type>(evt.GetInt());
|
||||||
auto *combo = static_cast<PresetComboBox*>(evt.GetEventObject());
|
auto *combo = static_cast<PresetComboBox*>(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();
|
auto idx = combo->get_extruder_idx();
|
||||||
|
|
||||||
//! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox,
|
//! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox,
|
||||||
|
@ -3637,7 +3645,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||||
//! combo->GetStringSelection().ToUTF8().data());
|
//! combo->GetStringSelection().ToUTF8().data());
|
||||||
|
|
||||||
const std::string preset_name = wxGetApp().preset_bundle->get_preset_name_by_alias(preset_type,
|
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) {
|
if (preset_type == Preset::TYPE_FILAMENT) {
|
||||||
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
|
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
void set_extruder_idx(const int extr_idx) { extruder_idx = extr_idx; }
|
void set_extruder_idx(const int extr_idx) { extruder_idx = extr_idx; }
|
||||||
int get_extruder_idx() const { return extruder_idx; }
|
int get_extruder_idx() const { return extruder_idx; }
|
||||||
int em_unit() const { return m_em_unit; }
|
int em_unit() const { return m_em_unit; }
|
||||||
void check_selection();
|
void check_selection(int selection);
|
||||||
|
|
||||||
void msw_rescale();
|
void msw_rescale();
|
||||||
|
|
||||||
|
|
|
@ -1253,7 +1253,7 @@ void PresetCollection::update_plater_ui(GUI::PresetComboBox *ui)
|
||||||
|
|
||||||
ui->SetSelection(selected_preset_item);
|
ui->SetSelection(selected_preset_item);
|
||||||
ui->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip);
|
ui->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip);
|
||||||
ui->check_selection();
|
ui->check_selection(selected_preset_item);
|
||||||
ui->Thaw();
|
ui->Thaw();
|
||||||
|
|
||||||
// Update control min size after rescale (changed Display DPI under MSW)
|
// Update control min size after rescale (changed Display DPI under MSW)
|
||||||
|
|
|
@ -1737,7 +1737,7 @@ void PresetBundle::update_plater_filament_ui(unsigned int idx_extruder, GUI::Pre
|
||||||
|
|
||||||
ui->SetSelection(selected_preset_item);
|
ui->SetSelection(selected_preset_item);
|
||||||
ui->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip);
|
ui->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip);
|
||||||
ui->check_selection();
|
ui->check_selection(selected_preset_item);
|
||||||
ui->Thaw();
|
ui->Thaw();
|
||||||
|
|
||||||
// Update control min size after rescale (changed Display DPI under MSW)
|
// Update control min size after rescale (changed Display DPI under MSW)
|
||||||
|
|
|
@ -229,7 +229,13 @@ void Tab::create_preset_tab()
|
||||||
//! but the OSX version derived from wxOwnerDrawnCombo, instead of:
|
//! but the OSX version derived from wxOwnerDrawnCombo, instead of:
|
||||||
//! select_preset(m_presets_choice->GetStringSelection().ToUTF8().data());
|
//! select_preset(m_presets_choice->GetStringSelection().ToUTF8().data());
|
||||||
//! we doing next:
|
//! 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())
|
if (m_selected_preset_item == size_t(selected_item) && !m_presets->current_is_dirty())
|
||||||
return;
|
return;
|
||||||
if (selected_item >= 0) {
|
if (selected_item >= 0) {
|
||||||
|
|
Loading…
Reference in a new issue