fix(ohos): fix attach window event to js

This commit is contained in:
etkmao
2025-12-05 14:52:14 +08:00
parent db3a53af1e
commit e694daccec
2 changed files with 4 additions and 1 deletions
@@ -195,6 +195,8 @@ protected:
std::function<void(const HRPosition &screenPosition)> eventTouchCancel_;
std::function<void()> eventAttachedToWindow_;
std::function<void()> eventDetachedFromWindow_;
bool attachEventHasSend_ = false;
bool flagInterceptPullUp_ = false;
@@ -834,11 +834,12 @@ void BaseView::SetAttachedToWindowHandle(bool flag) {
eventAttachedToWindow_ = [weak_view]() {
auto view = weak_view.lock();
if (view) {
view->attachEventHasSend_ = true;
HRGestureDispatcher::HandleAttachedToWindow(view->ctx_, view->tag_);
}
};
// NODE_EVENT_ON_ATTACH 事件是 insertChild 的时候触发的,所以如果已经 insert 过,需要补发事件
if (GetLocalRootArkUINode()->HasParent()) {
if (GetLocalRootArkUINode()->HasParent() && !attachEventHasSend_) {
eventAttachedToWindow_();
}
} else {