GestureSample icon indicating copy to clipboard operation
GestureSample copied to clipboard

Adding an MR control in the Header of a ListView does not establish AndroidGestureHandler

Open dalux-era opened this issue 1 year ago • 3 comments

I tried adding an MR gesture view n the header of a ListView on Android, none of the Gesture commands work.

public ListViewXaml()
{
	InitializeComponent();
	ListView = new ListView();
	ListView.Header = new MR.Gestures.Button(){Text = "Hi", TappedCommand = new Command(() => Console.WriteLine("HIIIIIIII")) };
}

It seems that in this case AndroidGestureHandler.AddInstance is not called as the commands of the Button are not added to the header of a ListView

dalux-era avatar Feb 14 '24 11:02 dalux-era

Found the problem here. MAUI does not call ConnectHandler in this case. Now I also instantiate the AndroidGestureHandler in DispatchTouchEvent if it's not there yet.

Fixed in Android, I'll check the other platforms too...

MichaelRumpler avatar Feb 22 '24 17:02 MichaelRumpler

Thanks! Should we create an issue on MAUI repo on the ConnectHandler not being initialized? Seems a bit scary that the header will not run the expected Handler.

dalux-era avatar Feb 23 '24 07:02 dalux-era

I debugged some more. ConnectHandler is called, but the Loaded event is never raised. I filed an issue for MAUI.

However, the gestures still don't work in the header. I do not know why yet, but I found a similar issue in MAUI

MichaelRumpler avatar Feb 27 '24 18:02 MichaelRumpler