Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow LayoutView to pass touches to child controls when CascadeInputTransparent is false #7236

Merged
merged 2 commits into from May 17, 2022

Conversation

hartez
Copy link
Contributor

@hartez hartez commented May 16, 2022

Description of Change

The default InputTransparent handling for LayoutView is disabling all user interaction, including with child controls. For situations where the Layout is InputTransparent but the child controls are not, this prevents interaction with the child controls.

These changes allow the LayoutView on iOS to pass touches through to child controls when it's corresponding Layout is InputTransparent, making it consistent with the other platforms.

This also removes some old code for enabling gestures on layouts that pre-dates the InputTransparent implementation for MAUI.Core (see #1190).

Issues Fixed

Fixes #6574

@jsuarezruiz jsuarezruiz added the area/layout 🔲 StackLayout, GridLayout, ScrollView, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label May 17, 2022
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@mattleibow
Copy link
Member

Is this correct behaviour? When we set a parent to input transparent, we still want the children to be hit?

Is there a way to say "make this layout and everything in it transparent"?

@hartez
Copy link
Contributor Author

hartez commented May 17, 2022

Is this correct behaviour? When we set a parent to input transparent, we still want the children to be hit?

Yes, this is correct. We want the option of setting a parent to be input transparent, while still allowing the children to be hit. Consider a UI with a map control, and an overlay with, say, a zoom slider and a couple of buttons. The layout which contains the overlay controls needs to be input transparent (so the user can interact with the map), but the controls it contains should not be input transparent.

Is there a way to say "make this layout and everything in it transparent"?

Yes, that's what the CascadeInputTransparent property mentioned in the title does.

@hartez hartez merged commit ad68647 into main May 17, 2022
@hartez hartez deleted the fix-6574 branch May 17, 2022 23:04
@emceelovin
Copy link

emceelovin commented May 26, 2022

Is this correct behaviour? When we set a parent to input transparent, we still want the children to be hit?

Yes, this is correct. We want the option of setting a parent to be input transparent, while still allowing the children to be hit. Consider a UI with a map control, and an overlay with, say, a zoom slider and a couple of buttons. The layout which contains the overlay controls needs to be input transparent (so the user can interact with the map), but the controls it contains should not be input transparent.

Is there a way to say "make this layout and everything in it transparent"?

Yes, that's what the CascadeInputTransparent property mentioned in the title does.

This is not the correct behavior/what should happen. MSDN specifically says CascadeInputTransparent is True by default. Which causes all children in a layout to inherit the InputTransparent value of the parent layout. E.g. InputTransparent="True" on a parent layout implicity sets InputTransparent="True" on all of it's children. This is logically what should happen. Since children will block antecedents, and you could have MANY MANY children, it's a LOT easier to set a cascading property that's inherited, which will be respected until another CascadeInputTransparency is found down in the tree, versus setting InputTransparent="True" on, depending on the complexity of the tree, a lot of UI elements. Either the docs need to be fixed, or the code needs to be fixed. I'd prefer the code to follow what the docs say IMO.

MAUI Layout documentation

The Layout class, from which all layouts derive, has a CascadeInputTransparent bindable property that controls whether child elements inherit the input transparency of the layout. Its default value is true, ensuring that setting the InputTransparent property to true on a layout class will result in all elements within the layout not receiving any input.

I found this issue searching for other input transparency issues to see if I could fix my own input issue #7489

@hartez
Copy link
Contributor Author

hartez commented May 26, 2022

This was a change for MAUI.Core to allow for the situation where CascadeInputTransparent is false. Without it, the CascadeInputTransparent property would be useless on iOS - it would effectively always be true.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/layout 🔲 StackLayout, GridLayout, ScrollView, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IOS] InputTransparency always cascaded to Children even when CascadeInputTransparent= false
4 participants