From ce2e53dbfa5469992e7a5b8bacec0d322c506c2f Mon Sep 17 00:00:00 2001 From: YuSanka Date: Sun, 5 Apr 2020 23:18:22 +0200 Subject: [PATCH] Added control of "Invalid numeric input" for the PointCtrl --- src/slic3r/GUI/Field.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index a1a6583bc..c9e91bd95 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1291,9 +1291,13 @@ void PointCtrl::set_value(const boost::any& value, bool change_event) boost::any& PointCtrl::get_value() { double x, y; - x_textctrl->GetValue().ToDouble(&x); - y_textctrl->GetValue().ToDouble(&y); - + if (!x_textctrl->GetValue().ToDouble(&x) || + !y_textctrl->GetValue().ToDouble(&y)) + { + set_value(m_value.empty() ? Vec2d(0.0, 0.0) : m_value, true); + show_error(m_parent, _L("Invalid numeric input.")); + } + else if (m_opt.min > x || x > m_opt.max || m_opt.min > y || y > m_opt.max) { @@ -1303,7 +1307,7 @@ boost::any& PointCtrl::get_value() if (y > m_opt.max) y = m_opt.max; set_value(Vec2d(x, y), true); - show_error(m_parent, _(L("Input value is out of range"))); + show_error(m_parent, _L("Input value is out of range")); } return m_value = Vec2d(x, y);