mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
!36563 add onchange when previewRange change
Merge pull request !36563 from 末日拿铁/for_add_onchange
This commit is contained in:
commit
39924826fc
@ -139,7 +139,7 @@ public:
|
||||
|
||||
void FireOnChange(const std::string& value, TextRange& range)
|
||||
{
|
||||
if (lastValue_.has_value() && lastValue_.value() == value) {
|
||||
if (lastValue_.has_value() && lastValue_.value() == value && lastPreviewRange_ == range) {
|
||||
return;
|
||||
}
|
||||
if (onValueChangeEvent_) {
|
||||
@ -152,6 +152,7 @@ public:
|
||||
onChange_(value, range);
|
||||
}
|
||||
lastValue_ = value;
|
||||
lastPreviewRange_ = range;
|
||||
}
|
||||
|
||||
void SetOnContentSizeChange(std::function<void(float, float)>&& func)
|
||||
@ -364,6 +365,7 @@ public:
|
||||
|
||||
private:
|
||||
std::optional<std::string> lastValue_;
|
||||
TextRange lastPreviewRange_ {};
|
||||
|
||||
OnScrollEvent onScrollEvent_;
|
||||
OnScrollBeginEvent onScrollBeginEvent_;
|
||||
|
@ -160,6 +160,7 @@ public:
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(TextLineStyle, TextIndent, Dimension, PROPERTY_UPDATE_MEASURE);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(TextLineStyle, NumberOfLines, int32_t, PROPERTY_UPDATE_MEASURE);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(Value, std::string, PROPERTY_UPDATE_NORMAL);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(PreviewRange, TextRange, PROPERTY_UPDATE_NORMAL);
|
||||
|
||||
ACE_DEFINE_PROPERTY_GROUP(PlaceholderFontStyle, FontStyle);
|
||||
ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP_ITEM(
|
||||
|
@ -2753,7 +2753,9 @@ bool TextFieldPattern::FireOnTextChangeEvent()
|
||||
}
|
||||
}
|
||||
auto textCache = layoutProperty->GetValueValue("");
|
||||
if (textCache == contentController_->GetTextValue()) {
|
||||
auto rangeCache = layoutProperty->GetPreviewRangeValue({-1, -1});
|
||||
TextRange curPreviewRange = {GetPreviewTextStart(), GetPreviewTextEnd()};
|
||||
if (textCache == contentController_->GetTextValue() && rangeCache == curPreviewRange) {
|
||||
return false;
|
||||
}
|
||||
host->OnAccessibilityEvent(AccessibilityEventType::TEXT_CHANGE, textCache, contentController_->GetTextValue());
|
||||
@ -2803,6 +2805,7 @@ void TextFieldPattern::AddTextFireOnChange()
|
||||
TextRange range;
|
||||
range.start = pattern->GetPreviewTextStart();
|
||||
range.end = pattern->GetPreviewTextEnd();
|
||||
layoutProperty->UpdatePreviewRange(range);
|
||||
eventHub->FireOnChange(pattern->GetTextContentController()->GetTextValue(), range);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user