diff options
Diffstat (limited to 'src/theme_builder/components/properties/PointPropertyEditor.cpp')
-rw-r--r-- | src/theme_builder/components/properties/PointPropertyEditor.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
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<ui::Point>(); - 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<ui::Point>(); + 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) { |