Fix the problem of bindMenu that the menu does not disappear when click outside the menu.

Signed-off-by: xuzhidan <xuzhidan1@huawei.com>
Change-Id: I743b5254cfd1cd4c1d4d78289dbd3cf5c8158e55
This commit is contained in:
xuzhidan
2022-03-21 10:35:43 +08:00
parent d4465c7a70
commit 5f125e58fc
@@ -35,6 +35,7 @@ RenderSelectPopup::RenderSelectPopup()
rawDetector_->SetOnTouchDown([weak = WeakClaim(this)](const TouchEventInfo& info) {
auto selectPopup = weak.Upgrade();
if (selectPopup) {
selectPopup->ProcessTouchDown(info);
selectPopup->HandleRawEvent(info.GetTouches().front().GetLocalLocation());
}
});
@@ -406,6 +407,12 @@ void RenderSelectPopup::ProcessTouchDown(const TouchEventInfo& info)
return;
}
auto clickPosition = touches.front().GetLocalLocation();
if (!touchRegion_.ContainsInRegion(clickPosition.GetX(), clickPosition.GetY())) {
LOGI("Do not contains the touch region.");
return;
}
firstFingerDownOffset_ = touches.front().GetGlobalLocation();
}
@@ -418,6 +425,12 @@ void RenderSelectPopup::ProcessTouchUp(const TouchEventInfo& info)
return;
}
auto clickPosition = touches.front().GetLocalLocation();
if (!touchRegion_.ContainsInRegion(clickPosition.GetX(), clickPosition.GetY())) {
LOGI("Do not contains the touch region.");
return;
}
if (selectPopup_->GetSelectOptions().empty()) {
return;
}
@@ -452,16 +465,6 @@ void RenderSelectPopup::OnTouchTestHit(
clickDetector_ = AceType::MakeRefPtr<ClickRecognizer>();
}
rawDetector_->SetOnTouchDown([weak = AceType::WeakClaim(this)](const TouchEventInfo& info) {
auto ref = weak.Upgrade();
if (!ref) {
LOGE("renderSelectPopup upgrade fail.");
return;
}
ref->ProcessTouchDown(info);
});
rawDetector_->SetOnTouchUp([weak = AceType::WeakClaim(this)](const TouchEventInfo& info) {
auto ref = weak.Upgrade();
if (!ref) {