!45039 fix 光标范围没变化 内容变化时候没有触发框架的onSelectionChange

Merge pull request !45039 from tzcurtain/caret_fix2
This commit is contained in:
openharmony_ci 2024-10-06 07:55:13 +00:00 committed by Gitee
commit 929218af9e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 4 additions and 2 deletions

View File

@ -710,11 +710,12 @@ void TextFieldPattern::UpdateCaretInfoToController(bool forceUpdate)
miscTextConfig.value().range.start, miscTextConfig.value().range.start,
miscTextConfig.value().range.end miscTextConfig.value().range.end
}; };
if (lastCursorRange_ == miscTextConfigRange && !forceUpdate) { if (!forceUpdate && lastCursorRange_ == miscTextConfigRange &&
lastTextValue_ == contentController_->GetTextValue()) {
return; return;
} }
lastCursorRange_.Set(miscTextConfig.value().range.start, miscTextConfig.value().range.end); lastCursorRange_.Set(miscTextConfig.value().range.start, miscTextConfig.value().range.end);
lastTextValue_ = contentController_->GetTextValue();
MiscServices::CursorInfo cursorInfo = miscTextConfig.value().cursorInfo; MiscServices::CursorInfo cursorInfo = miscTextConfig.value().cursorInfo;
MiscServices::InputMethodController::GetInstance()->OnCursorUpdate(cursorInfo); MiscServices::InputMethodController::GetInstance()->OnCursorUpdate(cursorInfo);
MiscServices::InputMethodController::GetInstance()->OnSelectionChange( MiscServices::InputMethodController::GetInstance()->OnSelectionChange(

View File

@ -1963,6 +1963,7 @@ private:
int32_t previewTextEnd_ = -1; int32_t previewTextEnd_ = -1;
std::string bodyTextInPreivewing_; std::string bodyTextInPreivewing_;
PreviewRange lastCursorRange_ = {}; PreviewRange lastCursorRange_ = {};
std::string lastTextValue_ = "";
bool showKeyBoardOnFocus_ = true; bool showKeyBoardOnFocus_ = true;
bool isTextSelectionMenuShow_ = true; bool isTextSelectionMenuShow_ = true;
bool isMoveCaretAnywhere_ = false; bool isMoveCaretAnywhere_ = false;