Working implementation of allowsHitTest() on Android#359
Working implementation of allowsHitTest() on Android#359marcprux merged 7 commits intoskiptools:mainfrom
allowsHitTest() on Android#359Conversation
…ouches to pass through" This reverts commit ee59fd3.
marcprux
left a comment
There was a problem hiding this comment.
Thanks for continuing to work on this.
One note is that I needed to implement a similar feature to get the new contextMenu() modifier to work on a Button element: #360. I wonder if using that technique would work here as well, and obviate the need for the custom HitTesting.kt node…
| @Composable static func RenderTextButton(label: View, context: ComposeContext, role: ButtonRole? = nil, isPlain: Bool = false, isEnabled: Bool = EnvironmentValues.shared.isEnabled, action: (() -> Void)? = nil) { | ||
| let isHitTestingEnabled = EnvironmentValues.shared._isHitTestingEnabled | ||
| if !isHitTestingEnabled { | ||
| print("SkipUI-HitTesting RenderTextButton hit testing disabled") |
There was a problem hiding this comment.
Need to remove print statement (you could change this to a Log.debug() call if you think it is useful).
| var context = context | ||
| context.modifier = context.modifier.skipHitTesting(enabled: enabled) | ||
| if !enabled { | ||
| print("SkipUI-HitTesting allowsHitTesting(false) applied to \(type(of: renderable))") |
There was a problem hiding this comment.
Another print statement that needs to be removed.
There was a problem hiding this comment.
I am new to the Android universe, so please take with a grain of salt:
As I understand it, pointerInput could help when the competing handlers are in the same event chain (typically parent-child), because you can choose pass/consumption behavior. It would not help however when the overlapping views are siblings, a fairly common scenario (e.g. in a ZStack)
Will clean up the logs + gate the new RenderContextMenu with _isHitTestingEnabled (so the contextual menu doesn't show when hit testing is disabled)
|
LGTM. Thanks for all the work on it! |
This PR competes with #354. #354 is a very limited/local bug fix. This PR is closer to a full implementation of
allowsHitTest()on AndroidCurrent implementation (Android behavior):
button1overbutton2=>button1handle the tapbutton1.allowsHitTest(false)overbutton2=>button1disabled + swallows the tap (no-one handles it). THIS IS WRONGtext1overbutton2=>button2handle the taptext1.allowsHitTest(false)overbutton2=>text1swallows the tap (no-one handles). THIS IS WRONG#354
button1overbutton2=>button1handle the tapbutton1.allowsHitTest(false)overbutton2=>button1handle the tap. THIS IS WRONGtext1overbutton2=>button2handle the tap (unlesstext1has a tap handler)text1.allowsHitTest(false)overbutton2=>button2handles the tapThis PR (as tested)
button1overbutton2=>button1handle the tapbutton1.allowsHitTest(false)overbutton2=>button2handle the tap.text1overbutton2=>button2handle the tap (unlesstext1has a tap handler)text1.allowsHitTest(false)overbutton2=>button2handles the tap (regardless of tap handler ontext1)Skip Pull Request Checklist:
swift testCodex generated the code under supervision. Tested manually from a native sandbox app