dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.71k forks source link

InputTransparent property makes all children disabled #23744

Open EitanRa opened 1 month ago

EitanRa commented 1 month ago

Description

Converting a Xamarin.Forms project to .NET MAUI, i'm facing a problem with a Microsoft.Maui.Controls.Maps.Map inside a ScrollView. In my Xamarin version, I set the ScrollView's InputTransparent property to true and everything worked well - the scroll view could scroll, the controls inside it responded to user input (button click and so on) and the map could scroll as well, without interrupts from its scroll view parent. But now in MAUI, after setting ScrollView's InputTransparent property to true (or any other view's InputTransparent property), the result is just as same as setting its IsEnabled property to true - all of the views inside the scroll view won't respond to any input! Here's the code: public class MyPage : ContentPage { public MyPage() { var sl = new StackLayout { Children = { new Button(), new Map() } }; Content = new ScrollView { InputTransparent = true, Content = sl }; return; } }

UPDATE: Found a solution for Android. Paste this code in MainActivity: `public override bool DispatchTouchEvent(MotionEvent e) { if (e.Action == MotionEventActions.Down || e.Action == MotionEventActions.Move || e.Action == MotionEventActions.Up) { // search MapView Control var maps = (Window.DecorView as ViewGroup).GetChildrenOfType();

    foreach (var map in maps)
    {
        // initialize MapView screen position 
        int[] pos = new int[2];

        // set MapView screen position
        map.GetLocationOnScreen(pos);

        // create hit test rectangle
        Rect hitRect = new Rect(pos[0], pos[1], pos[0] + map.Width, pos[1] + map.Height);

        // judge hit test
        bool isHitTest = hitRect.Contains((int)e.GetX(), (int)e.GetY());

        // hit test result is OK
        if (isHitTest)
        {
            // touch event intercept
            map.Parent.RequestDisallowInterceptTouchEvent(true);
        }
    }
}

return base.DispatchTouchEvent(e);

}` (source: https://github.com/dotnet/maui/issues/13628)

Steps to Reproduce

Create A .NET MAUI project > Installed Microsoft.Maui.Controls.Maps package version 7.0.59 > Tested on Android

Link to public reproduction project repository

No response

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

RoiChen001 commented 1 month ago

I can repro this issue at Android platform on the latest 17.11.0 Preview 5.0 (8.0.70 & 8.0.61). Sample project: https://github.com/cat0363/Maui-Issue13628

hflexgrig commented 1 month ago

The same problem on my side :( Any update there ?