FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add ability to pass touch event thru parent view by manoldonev · Pull Request #6204 · NativeScript/NativeScript · GitHub

feat: add ability to pass touch event thru parent view - #6204

Merged
manoldonev merged 14 commits into
masterfrom
mdonev/enhance-hittesting-support
Sep 18, 2018
Merged

manoldonev merged 14 commits into
masterfrom
mdonev/enhance-hittesting-support

Conversation

manoldonev commented Aug 21, 2018 •
edited
Loading

Copy link
Copy Markdown
Contributor

Enhance hit-testing support by introducing IsPassThroughParentEnabled property on all built-in layout containers (hence added to LayoutBase) that gets or sets a value indicating whether touch events should pass through to a parent view of the layout container in case an interactive child view did not handle it [the event].

Related to #6191
Depends on NativeScript/tns-core-modules-widgets#135

manoldonev self-assigned this Aug 21, 2018
ghost added the in progress label Aug 21, 2018
manoldonev requested a review from vakrilov August 21, 2018 18:04

farfromrefug commented Aug 22, 2018 •
edited
Loading

Copy link
Copy Markdown
Collaborator

@manoldonev Any chance for you to allow me to push on your branch. I have create a test and am testing all that.
I have an issue with making your tns-core-module-widgets work but I guess it s just my env.

EDIT: I don't think the android version is doing what it is supposed to do.
I have run some tests with your code and it does not "pass through". The view ignores the event but the parent does not handle it either.

manoldonev changed the title [WIP] feat: enhance hit-testing support [WIP] feat: add ability to pass touch event thru parent view Aug 30, 2018
manoldonev mentioned this pull request Aug 30, 2018

Copy link
Copy Markdown
Contributor Author

@SvetoslavTsenov Added apps/app/ui-tests-app/layouts/passThroughParent.xml for ui test automation -- ping me when you get back to discuss it.

manoldonev changed the title [WIP] feat: add ability to pass touch event thru parent view feat: add ability to pass touch event thru parent view Aug 31, 2018
NativeScript deleted a comment from SvetoslavTsenov Aug 31, 2018
NativeScript deleted a comment from SvetoslavTsenov Aug 31, 2018
NativeScript deleted a comment from SvetoslavTsenov Aug 31, 2018

farfromrefug commented Sep 3, 2018 •
edited
Loading

Copy link
Copy Markdown
Collaborator

@manoldonev Tell me if I am wrong but isn't isPassThroughParentEnabled only working with layouts from your implementation?
As you only implemented it in LayoutBase on android, I don't see how it would work for a label for example?

PS: it s actually not an issue in your framework as you can't add children to a label, image...

Copy link
Copy Markdown
Contributor Author

@farfromrefug yup, technically you are correct -- the reason I opted for the layout implementation is that I think we are not losing functionality in practice (i.e. cannot add children to label) and we already have a custom "native" widget for Android layouts so we do not need to introduce additional native wrappers to implement this. We really would like not to add additional containers for all elements, and the option to introduce such containers only if "pointer events" are enabled would complicate our code initialization logic.

farfromrefug commented Sep 3, 2018 •
edited
Loading

Copy link
Copy Markdown
Collaborator

@manoldonev finally managed to test this. I see only one issue.
On iOS the isEnabled=false seems to act as isUserInteractionEnabled=false and events pass through to parent when they should not (in my opinion).
For example if you have a disabled button over a map view it does not mean the touches should go through the button to the map I think. Android handles that correctly

Might this be that isUserInteractionEnabled is set to false when isEnabled is set to false?
https://stackoverflow.com/questions/34081153/ios-uibutton-difference-between-uibutton-setuserinteractionenabled-and-setenab#34081307

EDIT: For the rest is seems perfect! Thanks !!!

Copy link
Copy Markdown
Contributor Author

@farfromrefug I noticed the different behavior associated with IsEnabled on iOS and Android but I think it's just how each platform works --
https://stackoverflow.com/questions/3211790/uibutton-passes-touches-to-superview-when-disabled-how-can-i-avoid-this.

Copy link
Copy Markdown
Collaborator

@manoldonev i agree though I find it weird for a disabled button on iOS to be 'pass through'. Does not really make sense to me. Would have to run some test on basic native app to see if it the case. Really thinking about the map example it does not make sense to me

ghost assigned SvetoslavTsenov Sep 7, 2018

Copy link
Copy Markdown
Contributor

@manoldonev, can you check the example again since on my side the app is crashing

JS: Navigation: NAVIGATE CORE(Page(54)@file:///app/ui-tests-app/layouts/passThroughParent.xml:1:1;); currentPage: Page(38)@file:///app/ui-tests-app/layouts/main-page.xml:2:1; JS: Transition: fragment1[1] Transitions:transitionName=default, JS: Transition: fragment2[2] Transitions:transitionName=default, JS: NativeLifecycle: fragment2[2]<Page(54)@file:///app/ui-tests-app/layouts/passThroughParent.xml:1:1;>.onCreate(null) JS: NativeLifecycle: fragment1[1]<Page(38)@file:///app/ui-tests-app/layouts/main-page.xml:2:1;>.onDestroyView() JS: NativeLifecycle: fragment1[1]<Page(38)@file:///app/ui-tests-app/layouts/main-page.xml:2:1;>.onCreateAnimation(4097, exit, exit): animation JS: NativeLifecycle: fragment2[2]<Page(54)@file:///app/ui-tests-app/layouts/passThroughParent.xml:1:1;>.onCreateView(inflater, container, null) 09-14 14:36:50.702 6078 6078 E AndroidRuntime: at com.tns.Runtime.callJSMethodNative(Native Method) 09-14 14:36:50.702 6078 6078 E AndroidRuntime: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116) 09-14 14:36:50.702 6078 6078 E AndroidRuntime: at com.tns.Runtime.callJSMethodImpl(Runtime.java:996) 09-14 14:36:50.702 6078 6078 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:983) 09-14 14:36:50.702 6078 6078 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:967) 09-14 14:36:50.702 6078 6078 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:959) System.err: com.tns.NativeScriptException: System.err: Calling js method onCreateView failed System.err: System.err: TypeError: this.nativeViewProtected.setPassThroughParent is not a function System.err: File: "file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base.js, line: 19, column: 33 System.err: System.err: StackTrace: System.err: Frame: function:'LayoutBase.(anonymous function)', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base.js', line: 19, column: 34 System.err: Frame: function:'applyAllNativeSetters', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js', line: 960, column: 28 System.err: Frame: function:'initNativeView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js', line: 904, column: 9 System.err: Frame: function:'ViewBase.onResumeNativeUpdates', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 627, column: 22 System.err: Frame: function:'ViewBase._resumeNativeUpdates', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 272, column: 18 System.err: Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 231, column: 14 System.err: Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 208, column: 35 System.err: Frame: function:'', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90 System.err: Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9 System.err: Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14 System.err: Frame: function:'ViewBase.loadView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 439, column: 18 System.err: Frame: function:'', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 233, column: 19 System.err: Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26 System.err: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14 System.err: Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 232, column: 14 System.err: Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 208, column: 35 System.err: Frame: function:'', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90 System.err: Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9 System.err: Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14 System.err: Frame: function:'ViewBase.loadView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 439, column: 18 System.err: Frame: function:'', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 233, column: 19 System.err: Frame: function:'ContentView.eachChildView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13 System.err: Frame: function:'PageBase.eachChildView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/page/page-common.js', line: 120, column: 40 System.err: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14 System.err: Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 232, column: 14 System.err: Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 208, column: 35 System.err: Frame: function:'Page.onLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/page/page.js', line: 43, column: 35 System.err: Frame: function:'', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90 System.err: Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9 System.err: Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14 System.err: Frame: function:'ViewBase.loadView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 439, column: 18 System.err: Frame: function:'ViewBase._addViewCore', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 434, column: 18 System.err: Frame: function:'ViewBase._addView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 420, column: 14 System.err: Frame: function:'FragmentCallbacksImplementation.onCreateView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 574, column: 24 System.err: Frame: function:'FragmentClass.onCreateView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/frame/fragment.js', line: 26, column: 38 System.err: System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:996) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:983) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:967) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:959) System.err: at com.tns.FragmentClass.onCreateView(FragmentClass.java:45) System.err: at android.support.v4.app.Fragment.performCreateView(Fragment.java:2239) System.err: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1332) System.err: at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1574) System.err: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1641) System.err: at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794) System.err: at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415) System.err: at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200) System.err: at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2153) System.err: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2063) System.err: at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:725) System.err: at android.os.Handler.handleCallback(Handler.java:873) System.err: at android.os.Handler.dispatchMessage(Handler.java:99) System.err: at android.os.Looper.loop(Looper.java:193) System.err: at android.app.ActivityThread.main(ActivityThread.java:6669) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) JS: ### NativeScriptError: Error: The application crashed because of an uncaught exception. You can look at "stackTrace" or "nativeException" for more detailed information about the exception. JS: ### nativeException: com.tns.NativeScriptException: JS: Calling js method onCreateView failed JS: JS: TypeError: this.nativeViewProtected.setPassThroughParent is not a function JS: File: "file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base.js, line: 19, column: 33 JS: JS: StackTrace: JS: Frame: function:'LayoutBase.(anonymous function)', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base.js', line: 19, column: 34 JS: Frame: function:'applyAllNativeSetters', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js', line: 960, column: 28 JS: Frame: function:'initNativeView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js', line: 904, column: 9 JS: Frame: function:'ViewBase.onResumeNativeUpdates', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base... JS: ### stackTrace: An uncaught Exception occurred on "main" thread. JS: com.tns.NativeScriptException: JS: Calling js method onCreateView failed JS: JS: TypeError: this.nativeViewProtected.setPassThroughParent is not a function JS: File: "file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base.js, line: 19, column: 33 JS: JS: StackTrace: JS: Frame: function:'LayoutBase.(anonymous function)', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base.js', line: 19, column: 34 JS: Frame: function:'applyAllNativeSetters', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js', line: 960, column: 28 JS: Frame: function:'initNativeView', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js', line: 904, column: 9 JS: Frame: function:'ViewBase.onResumeNativeUpdates', file:'file:///data/data/org.nativescript.apps/files/app/tns_modules/... JS: ### stack: Error: The application crashed because of an uncaught exception. You can look at "stackTrace" or "nativeException" for more detailed information about the exception. JS: The application crashed because of an uncaught exception. You can look at "stackTrace" or "nativeException" for more detailed information about the exception.

SvetoslavTsenov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Check example again. It is not working on my side.

Copy link
Copy Markdown
Contributor Author

@SvetoslavTsenov are you using NativeScript/tns-core-modules-widgets#135 for tns-core-modules-widgets reference?

Copy link
Copy Markdown
Collaborator

@SvetoslavTsenov @manoldonev had a lot of difficulties getting the link tns-core-modules-widgets to work. And i had the exact same error before i managed to get it to work.
Must be a simple config error.

Copy link
Copy Markdown
Contributor Author

test branch-tns-core-modules-widgets#mdonev/enhance-hittesting-support

Copy link
Copy Markdown
Contributor

@manoldonev, I missed the part with widgets :)

manoldonev merged commit 2625683 into master Sep 18, 2018
manoldonev deleted the mdonev/enhance-hittesting-support branch September 18, 2018 15:59
ghost removed the in progress label Sep 18, 2018
manoldonev added the docs needed Additional documentation on this issue/PR is needed label Sep 19, 2018
NickIliev removed the docs needed Additional documentation on this issue/PR is needed label Jan 11, 2019

lock Bot commented Mar 10, 2020

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock Bot locked and limited conversation to collaborators Mar 10, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL