From 9b3b13f78fffefb18f64aad88891d36009a8052e Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 17 Feb 2022 16:28:13 +0800 Subject: ... --- .../components/properties/PointPropertyEditor.cpp | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/theme_builder/components/properties/PointPropertyEditor.cpp') diff --git a/src/theme_builder/components/properties/PointPropertyEditor.cpp b/src/theme_builder/components/properties/PointPropertyEditor.cpp index 702b26e8..60f3c06c 100644 --- a/src/theme_builder/components/properties/PointPropertyEditor.cpp +++ b/src/theme_builder/components/properties/PointPropertyEditor.cpp @@ -9,17 +9,21 @@ PointPropertyEditor::PointPropertyEditor() { container_.AddChild(&text_); text_.TextChangeEvent()->AddHandler([this](std::nullptr_t) { - auto text = text_.GetTextView(); - auto point_mapper = - ui::mapper::MapperRegistry::GetInstance()->GetMapper(); - try { - auto point = point_mapper->MapFromString(text.ToString()); - point_ = point; - is_text_valid_ = true; - change_event_.Raise(nullptr); - } catch (const Exception&) { - is_text_valid_ = false; - // TODO: Show error! + if (!suppress_next_change_event_) { + auto text = text_.GetTextView(); + auto point_mapper = + ui::mapper::MapperRegistry::GetInstance()->GetMapper(); + try { + auto point = point_mapper->MapFromString(text.ToString()); + point_ = point; + is_text_valid_ = true; + change_event_.Raise(nullptr); + } catch (const Exception&) { + is_text_valid_ = false; + // TODO: Show error! + } + } else { + suppress_next_change_event_ = false; } }); } @@ -29,9 +33,9 @@ PointPropertyEditor::~PointPropertyEditor() {} void PointPropertyEditor::SetValue(const ui::Point& point, bool trigger_change) { point_ = point; - text_.SetText(ConvertPointToString(point)); is_text_valid_ = true; - if (trigger_change) change_event_.Raise(nullptr); + if (!trigger_change) suppress_next_change_event_ = true; + text_.SetText(ConvertPointToString(point)); } String PointPropertyEditor::ConvertPointToString(const ui::Point& point) { -- cgit v1.2.3