From fb7895768729521cdcb0562a2b39be814f8cf584 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 21 Dec 2018 10:58:00 +0100 Subject: [PATCH] Fixed updating of settings after selection of the preset with "modified" suffix + Added EVT_SPINCTRL binding --- src/slic3r/GUI/Field.cpp | 12 +++++++----- src/slic3r/GUI/Plater.cpp | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 1bc4c7305..9855806be 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -400,10 +400,11 @@ void SpinCtrl::BUILD() { auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, 0, min_val, max_val, default_value); -// temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { tmp_value = undef_spin_val; on_change_field(); }), temp->GetId()); - +#ifndef __WXOSX__ // #ys_FIXME_KILL_FOCUS - // wxEVT_KILL_FOCUS doesn't handled on OSX now + // wxEVT_KILL_FOCUS doesn't handled on OSX now (wxWidgets 3.1.1) + // So, we will update values on KILL_FOCUS & SPINCTRL events under MSW and GTK + // and on TEXT event under OSX temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { if (tmp_value < 0) @@ -414,6 +415,9 @@ void SpinCtrl::BUILD() { } }), temp->GetId()); + temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId()); +#endif + temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { // # On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value @@ -425,9 +429,7 @@ void SpinCtrl::BUILD() { if (is_matched(value, "^\\d+$")) tmp_value = std::stoi(value); else tmp_value = -9999; -// on_change_field(); #ifdef __WXOSX__ - // #ys_FIXME_KILL_FOCUS so call on_change_field() inside wxEVT_TEXT if (tmp_value < 0) { if (m_on_kill_focus != nullptr) m_on_kill_focus(m_opt_id); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f3892e475..1111763e0 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -224,7 +224,8 @@ PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) : if (marker == LABEL_ITEM_MARKER) { this->SetSelection(this->last_selected); evt.StopPropagation(); - } else if (this->last_selected != selected_item) { + } else if ( this->last_selected != selected_item || + wxGetApp().get_tab(this->preset_type)->get_presets()->current_is_dirty() ) { this->last_selected = selected_item; evt.SetInt(this->preset_type); evt.Skip();