From c6b597b8138f464265d26def3d3cba60f21fb140 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 21 Nov 2018 15:02:22 +0100 Subject: [PATCH] Fixed updating of the options values after the clearing of the TextCtrl --- src/slic3r/GUI/Field.cpp | 23 ++++++++++++++++++----- src/slic3r/GUI/Field.hpp | 3 ++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 68d3948bb..bc1a5c1e9 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -161,6 +161,13 @@ void Field::get_value_by_opt_type(wxString& str) } } +bool TextCtrl::is_defined_input_value() +{ + if (static_cast(window)->GetValue().empty() && m_opt.type != coString && m_opt.type != coStrings) + return false; + return true; +} + void TextCtrl::BUILD() { auto size = wxSize(wxDefaultSize); if (m_opt.height >= 0) size.SetHeight(m_opt.height); @@ -226,16 +233,21 @@ void TextCtrl::BUILD() { temp->GetToolTip()->Enable(flag); }), temp->GetId()); -#if !defined(__WXGTK__) temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e) { - e.Skip();// on_kill_focus(e); +#if !defined(__WXGTK__) + e.Skip(); temp->GetToolTip()->Enable(true); - }), temp->GetId()); #endif // __WXGTK__ + if (!is_defined_input_value()) + on_kill_focus(e); + }), temp->GetId()); if (m_process_enter) { - temp->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent& evt) { on_change_field(); }), temp->GetId()); + temp->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent& evt) { + if(is_defined_input_value()) + on_change_field(); + }), temp->GetId()); } else { temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent& evt) @@ -243,6 +255,7 @@ void TextCtrl::BUILD() { #ifdef __WXGTK__ if (bChangedValueEvent) #endif //__WXGTK__ + if(is_defined_input_value()) on_change_field(); }), temp->GetId()); @@ -357,7 +370,7 @@ void SpinCtrl::BUILD() { 0, min_val, max_val, default_value); // temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { tmp_value = undef_spin_val; on_change_field(); }), temp->GetId()); -// temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { tmp_value = undef_spin_val; on_kill_focus(e); }), temp->GetId()); + temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { on_kill_focus(e); }), temp->GetId()); temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { // # On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index 29ae6f9ce..87ec0c1da 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -265,7 +265,8 @@ public: } boost::any& get_value() override; - + bool is_defined_input_value(); + virtual void enable(); virtual void disable(); virtual wxWindow* getWindow() { return window; }