aboutsummaryrefslogtreecommitdiff
path: root/src/theme_builder/components/properties/PointPropertyEditor.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-17 16:28:13 +0800
committercrupest <crupest@outlook.com>2022-02-17 16:28:13 +0800
commit9b3b13f78fffefb18f64aad88891d36009a8052e (patch)
tree6f5b7e45607b021a4aa0fc1fd2de29ec916d8bcd /src/theme_builder/components/properties/PointPropertyEditor.cpp
parent77e0fd5cf7dd35324a7c3a43f2004fb923c6254c (diff)
downloadcru-9b3b13f78fffefb18f64aad88891d36009a8052e.tar.gz
cru-9b3b13f78fffefb18f64aad88891d36009a8052e.tar.bz2
cru-9b3b13f78fffefb18f64aad88891d36009a8052e.zip
...
Diffstat (limited to 'src/theme_builder/components/properties/PointPropertyEditor.cpp')
-rw-r--r--src/theme_builder/components/properties/PointPropertyEditor.cpp30
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) {