From 283cee3f27156231a84a278c8ba29d52a0795d4d Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 19 Aug 2019 12:58:59 +0200 Subject: [PATCH] Fixed SPE-1000. Since the value inserted from the keyboard or clipboard is not updated under OSX, we forcibly set the input value for SpinControl every time during editing. Thus we can't set min control value bigger then 0. Otherwise, it couldn't be possible to input from keyboard value less then min_val. --- src/libslic3r/PrintConfig.cpp | 4 ++-- src/slic3r/GUI/Field.cpp | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index fd5b699ac..31de80e8b 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2306,13 +2306,13 @@ void PrintConfigDef::init_sla_params() def->full_label = L("Number of pixels in"); def->label = ("X"); def->tooltip = L("Number of pixels in X"); - def->min = 1; + def->min = 100; def->set_default_value(new ConfigOptionInt(2560)); def = this->add("display_pixels_y", coInt); def->label = ("Y"); def->tooltip = L("Number of pixels in Y"); - def->min = 1; + def->min = 100; def->set_default_value(new ConfigOptionInt(1440)); def = this->add("display_mirror_x", coBool); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 39924e44c..252b9d6c5 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -559,7 +559,16 @@ void SpinCtrl::BUILD() { break; } - const int min_val = m_opt.min == INT_MIN ? 0: m_opt.min; + const int min_val = m_opt.min == INT_MIN +#ifdef __WXOSX__ + // We will forcibly set the input value for SpinControl, since the value + // inserted from the keyboard is not updated under OSX. + // So, we can't set min control value bigger then 0. + // Otherwise, it couldn't be possible to input from keyboard value + // less then min_val. + || m_opt.min > 0 +#endif + ? 0 : m_opt.min; const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647; auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, @@ -631,6 +640,14 @@ void SpinCtrl::propagate_value() if (tmp_value == UNDEF_VALUE) { on_kill_focus(); } else { +#ifdef __WXOSX__ + // check input value for minimum + if (m_opt.min > 0 && tmp_value < m_opt.min) { + wxSpinCtrl* spin = static_cast(window); + spin->SetValue(m_opt.min); + spin->GetText()->SetInsertionPointEnd(); + } +#endif on_change_field(); } }