Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2019-07-30 15:16:07 +0300
committerYuSanka <yusanka@gmail.com>2019-07-30 15:16:07 +0300
commit7c2e199472524c40bbd3f50650c2a0c7345bd4dd (patch)
treeba9b8f62be091a4787a9b40c38c98ede1fc838ee /src/slic3r/GUI/Field.cpp
parentb7d6c93c36800cec7bbbc42f084adfca3d09c269 (diff)
Try to fix selection of overridden option when TextCtrl is focused
Note: the problem was observed only under OSX
Diffstat (limited to 'src/slic3r/GUI/Field.cpp')
-rw-r--r--src/slic3r/GUI/Field.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp
index 14386f381..ca1c57bc5 100644
--- a/src/slic3r/GUI/Field.cpp
+++ b/src/slic3r/GUI/Field.cpp
@@ -342,9 +342,40 @@ void TextCtrl::BUILD() {
window = dynamic_cast<wxWindow*>(temp);
}
+bool TextCtrl::value_was_changed()
+{
+ if (m_value.empty())
+ return true;
+
+ boost::any val = m_value;
+ wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
+ // update m_value!
+ get_value_by_opt_type(ret_str);
+
+ switch (m_opt.type) {
+ case coInt:
+ return boost::any_cast<int>(m_value) != boost::any_cast<int>(val);
+ case coPercent:
+ case coPercents:
+ case coFloats:
+ case coFloat: {
+ if (m_opt.nullable && std::isnan(boost::any_cast<double>(m_value)) &&
+ std::isnan(boost::any_cast<double>(val)))
+ return false;
+ return boost::any_cast<double>(m_value) != boost::any_cast<double>(val);
+ }
+ case coString:
+ case coStrings:
+ case coFloatOrPercent:
+ return boost::any_cast<std::string>(m_value) != boost::any_cast<std::string>(val);
+ default:
+ return true;
+ }
+}
+
void TextCtrl::propagate_value()
{
- if (is_defined_input_value<wxTextCtrl>(window, m_opt.type))
+ if (is_defined_input_value<wxTextCtrl>(window, m_opt.type) && value_was_changed())
on_change_field();
else
on_kill_focus();