!37799 修复TextInput手写笔输入点击清除按钮无效

Merge pull request !37799 from kangshihui/text_dev
This commit is contained in:
openharmony_ci 2024-07-16 01:21:55 +00:00 committed by Gitee
commit 85ecbea640
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 41 additions and 1 deletions

View File

@ -318,7 +318,7 @@ RefPtr<NG::FrameNode> StylusDetectorMgr::FindTextInputFrameNodeByPosition(float
auto globalFrameRect = geometryNode->GetFrameRect() + NG::SizeF(0, HOT_AREA_ADJUST_SIZE.ConvertToPx() * 2);
globalFrameRect.SetOffset(frameNode->CalculateCachedTransformRelativeOffset(nanoTimestamp) +
NG::OffsetF(0, -HOT_AREA_ADJUST_SIZE.ConvertToPx()));
if (globalFrameRect.IsInRegion(point)) {
if (globalFrameRect.IsInRegion(point) && !IsHitCleanNodeResponseArea(point, frameNode, nanoTimestamp)) {
hitFrameNodes.insert(frameNode);
}
}
@ -344,4 +344,30 @@ bool StylusDetectorMgr::IsStylusTouchEvent(const TouchEvent& touchEvent) const
{
return touchEvent.sourceTool == SourceTool::PEN && touchEvent.type == TouchType::DOWN;
}
bool StylusDetectorMgr::IsHitCleanNodeResponseArea(
const NG::PointF& point, const RefPtr<NG::FrameNode>& frameNode, uint64_t nanoTimestamp)
{
CHECK_NULL_RETURN(frameNode, false);
if (frameNode->GetTag() != V2::TEXTINPUT_ETS_TAG) {
return false;
}
auto textFieldPattern = frameNode->GetPattern<NG::TextFieldPattern>();
CHECK_NULL_RETURN(textFieldPattern, false);
auto responseArea = textFieldPattern->GetCleanNodeResponseArea();
CHECK_NULL_RETURN(responseArea, false);
auto cleanNodeResponseArea = AceType::DynamicCast<NG::CleanNodeResponseArea>(responseArea);
if (!cleanNodeResponseArea->IsShow()) {
return false;
}
auto cleanNodeFrameNode = cleanNodeResponseArea->GetFrameNode();
CHECK_NULL_RETURN(cleanNodeFrameNode, false);
auto cleanNodeGeometryNode = cleanNodeFrameNode->GetGeometryNode();
CHECK_NULL_RETURN(cleanNodeGeometryNode, false);
auto globalFrameRect = cleanNodeGeometryNode->GetFrameRect();
globalFrameRect.SetOffset(cleanNodeFrameNode->CalculateCachedTransformRelativeOffset(nanoTimestamp));
return globalFrameRect.IsInRegion(point);
}
} // namespace OHOS::Ace

View File

@ -82,4 +82,10 @@ bool StylusDetectorMgr::IsStylusTouchEvent(const TouchEvent& touchEvent) const
{
return false;
}
bool StylusDetectorMgr::IsHitCleanNodeResponseArea(
const NG::PointF& point, const RefPtr<NG::FrameNode>& frameNode, uint64_t nanoTimestamp)
{
return false;
}
} // namespace OHOS::Ace

View File

@ -75,6 +75,8 @@ private:
};
bool IsStylusTouchEvent(const TouchEvent& touchEvent) const;
bool IsHitCleanNodeResponseArea(
const NG::PointF& point, const RefPtr<NG::FrameNode>& frameNode, uint64_t nanoTimestamp);
RefPtr<NG::FrameNode> FindTextInputFrameNodeByPosition(float globalX, float globalY);

View File

@ -82,4 +82,10 @@ bool StylusDetectorMgr::IsStylusTouchEvent(const TouchEvent& touchEvent) const
{
return false;
}
bool StylusDetectorMgr::IsHitCleanNodeResponseArea(
const NG::PointF& point, const RefPtr<NG::FrameNode>& frameNode, uint64_t nanoTimestamp)
{
return false;
}
} // namespace OHOS::Ace