From f67060f0129cbe897e6a144b8181146c35ace174 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 5 Sep 2018 09:47:36 +0200 Subject: [PATCH] Fixed bug from issue #1169 --- xs/src/slic3r/GUI/Field.cpp | 23 +++++++++++++++-------- xs/src/slic3r/GUI/Field.hpp | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 757a18f11..44cdb33f5 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -234,14 +234,10 @@ namespace Slic3r { namespace GUI { }), temp->GetId()); #ifdef __WXGTK__ - temp->Bind(wxEVT_KEY_UP, [this](wxKeyEvent& event) - { - if (bChangedValueEvent) { - on_change_field(); - bChangedValueEvent = false; - } - event.Skip(); - }); + // to correct value update on GTK we should call on_change_field() on + // wxEVT_KEY_UP or wxEVT_TEXT_PASTE instead of wxEVT_TEXT + temp->Bind(wxEVT_KEY_UP, &TextCtrl::change_field_value, this); + temp->Bind(wxEVT_TEXT_PASTE, &TextCtrl::change_field_value, this); #endif //__WXGTK__ // select all text using Ctrl+A @@ -267,6 +263,17 @@ namespace Slic3r { namespace GUI { void TextCtrl::enable() { dynamic_cast(window)->Enable(); dynamic_cast(window)->SetEditable(true); } void TextCtrl::disable() { dynamic_cast(window)->Disable(); dynamic_cast(window)->SetEditable(false); } +#ifdef __WXGTK__ + void TextCtrl::change_field_value(wxEvent& event) + { + if (bChangedValueEvent) { + on_change_field(); + bChangedValueEvent = false; + } + event.Skip(); + }; +#endif //__WXGTK__ + void CheckBox::BUILD() { auto size = wxSize(wxDefaultSize); if (m_opt.height >= 0) size.SetHeight(m_opt.height); diff --git a/xs/src/slic3r/GUI/Field.hpp b/xs/src/slic3r/GUI/Field.hpp index db8d2a408..67c7692fc 100644 --- a/xs/src/slic3r/GUI/Field.hpp +++ b/xs/src/slic3r/GUI/Field.hpp @@ -223,6 +223,7 @@ class TextCtrl : public Field { using Field::Field; #ifdef __WXGTK__ bool bChangedValueEvent = false; + void change_field_value(wxEvent& event); #endif //__WXGTK__ public: TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}