| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
Fix: Add support for handling ArkTS touches for FallbackComponentInstance. Co-authored-by: 谢代荣<xiedairong@huawei.com> # message auto-generated for no-merge-commit merge: merge master-bindsheet into master Fix: Add support for handling ArkTS touches for FallbackComponentInstance. Created-by: xiedrsz Commit-by: 谢代荣 Merged-by: huangyouhua Description: ## Description This merge request introduces a fix for issues related to touch event detection in components placed inside ArkTS modal-like elements such as Sheet. Currently, React children placed inside modals (e.g., via .bindSheet in a custom ArkTS component) do not detect touch events correctly. This is because touch event detection relies solely on the CAPI UIInputTouchEvents. However, when an ArkTS component uses a modal, the touch event is detected only on the ArkTS side and is not propagated to the C++. To address this, a new method has been introduced to the ArkTS RNInstance: postTouchEventMessageToCpp. This method accepts the tag of the root touch target component along with a TouchEvent object and forwards them to the C++. The FallbackComponentInstance, used for custom ArkTS components, has been extended to also inherit from the ArkTS observer. This allows it to listen for touch events from ArkTS. When a touch event with the appropriate tag is received, it is dispatched using a modified TouchEventDispatcher, which now handles both CAPI and ArkTS touch events. Another issue with modal-like components is caused by the differences with JS and native component tree hierarchy. Touch events can still be triggered on components inside a Sheet, even after the Sheet is dismissed and no longer visible. From the JS perspective, the modal root component might still appear as a child of other components, leading to unintended touch propagation. To resolve this, a new method isRootTouchTarget() has been added to the touch target interface. Components that serve as root touch targets can override this method. During the search for touchable children, any such root components are excluded from further propagation. This prevents touch events from being dispatched to dismissed or inactive modal components. In order to detect touch events properly in components like.bindSheet touch event must be intercepted on ArkTs side and forwarded to C++ with postTouchEventMessageToCpp, the example usage is presented in ContainerViewWithModal.ets. It important that .onTouch(…) should be placed inside a builder that is passed to .bindSheet, here’s example usage: tsx @Builder myBuilder() { Column(){ ContentSlot(this.ctx.getContentForTag(this.tag)) } .width('100%') .height('100%') .onTouch((event: TouchEvent) => {this.ctx.rnInstance.postTouchEventMessageToCpp(this.tag, event)}) } build() { RNViewBase({ tag: this.tag, ctx: this.ctx }) { Stack(){}.bindSheet(true, this.myBuilder()) } } ## Changes - modified TouchEventDispatcher to handle both CAPI and ArkTS touch events - added postTouchEventMessageToCpp method to rn instance to forward arkTs events to component instances - modified fallbackComponentInstance to handle touch events form ArkTS ## Test Plan 1. Run tester app 1. Open CustomComponentTest 1. Run ContainerViewWithModalTest and check if button in sheet can be clicked ## Checklist - [x] Does not involve incompatible changes; if involved, has been reviewed accordingly. - [x] Does not impact performance, or performance testing has been conducted without degradation. - [x] Complies with the relevant coding standards. - [x] Does not involve documentation updates, or the documentation has been updated. - [x] Meets testability requirements with necessary self-test cases, appropriate logging, or trace information added. - [x] No illegal file inclusions exist, such as images or code. See merge request: openharmony-sig/ohos_react_native!1601 | 1 年前 | |
Added sample-packlage/package-lock.json to gitignore Signed-off-by: hyh <huangyouhua2@huawei.com> | 2 年前 | |
chore: extract react-native-harmony-sample-package Signed-off-by: hyh <huangyouhua2@huawei.com> | 2 年前 | |
chore: extract react-native-harmony-sample-package Signed-off-by: hyh <huangyouhua2@huawei.com> | 2 年前 | |
add the Copyright-Notice for HUAWEI Signed-off-by: 木叶纷下 <694161290@qq.com> | 1 年前 | |
[chore]: updated to version 6.1.0.300(0.72.118) Signed-off-by: dengjiangtao <1442949715@qq.com> | 8 个月前 |
Sample Package
This project is an example of a harmony specific package.
harmony directory
Open Harmony module will be copied here after running react-native pack-harmony. Currently, Open Harmony modules can't be installed, if they are placed outside Open Harmony project. An app developer needs to run react-native unpack-harmony after installation, to move those modules into harmony project. THe native code is in the tester project to allow fast development cycles.