diff options
author | crupest <crupest@outlook.com> | 2022-02-17 18:32:52 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-17 18:32:52 +0800 |
commit | ada641977cd57a50fc862243ba256c58efc065b8 (patch) | |
tree | 0f2124b88496f42e2cce2e3aaa64211131c18b37 /src/theme_builder/components/properties/PointPropertyEditor.cpp | |
parent | 9b3b13f78fffefb18f64aad88891d36009a8052e (diff) | |
download | cru-ada641977cd57a50fc862243ba256c58efc065b8.tar.gz cru-ada641977cd57a50fc862243ba256c58efc065b8.tar.bz2 cru-ada641977cd57a50fc862243ba256c58efc065b8.zip |
...
Diffstat (limited to 'src/theme_builder/components/properties/PointPropertyEditor.cpp')
-rw-r--r-- | src/theme_builder/components/properties/PointPropertyEditor.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/theme_builder/components/properties/PointPropertyEditor.cpp b/src/theme_builder/components/properties/PointPropertyEditor.cpp index 60f3c06c..6d4277aa 100644 --- a/src/theme_builder/components/properties/PointPropertyEditor.cpp +++ b/src/theme_builder/components/properties/PointPropertyEditor.cpp @@ -9,21 +9,17 @@ PointPropertyEditor::PointPropertyEditor() { container_.AddChild(&text_); text_.TextChangeEvent()->AddHandler([this](std::nullptr_t) { - 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; + 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; + RaiseChangeEvent(); + } catch (const Exception&) { + is_text_valid_ = false; + // TODO: Show error! } }); } @@ -32,9 +28,7 @@ PointPropertyEditor::~PointPropertyEditor() {} void PointPropertyEditor::SetValue(const ui::Point& point, bool trigger_change) { - point_ = point; - is_text_valid_ = true; - if (!trigger_change) suppress_next_change_event_ = true; + if (!trigger_change) SuppressNextChangeEvent(); text_.SetText(ConvertPointToString(point)); } |