roubachof / Sharpnado.Presentation.Forms

Presentation layer: Xamarin Forms custom components and renderers
594 stars 74 forks source link

TapGestureRecognizer on TabButton will not recognize taps on button itself - Only on button background #91

Closed jbachelor closed 4 years ago

jbachelor commented 4 years ago

Platform (please complete the following information):

Describe the bug First, thank you so much for this awesome library, sample code, and super helpful blog posts. Sharpnado is allowing me to create the exact look and feel I was hoping for!

It appears there is no 'Clicked' event on the TabButton, and I wanted to run a small animation when the button was tapped. I added a TapGestureRecognizer to the TabButton, and tried to animate the button when tapped. However, the button itself does not seem to register the taps... Only the area of the TabButton that is not the button, but rather the background, responds to taps.

I also wired up the TapCommand to an ICommand in my view model, and it responds to taps of the button area itself, but not the background, which is perfect. I would have expected the TapGestureRecognizer to cover the whole control.

To Reproduce Steps to reproduce the behavior:

NOTE: Screenshots of code changes made provided below.

  1. Add a x:Name attribute to the TabButton so you can reference it in the code-behind.
  2. Add a TapGestureRecognizer to the TabButton, and a corresponding handler in the code-behind.
  3. To make life easier, add a BackgroundColor attribute to the TabButton, so you can see where the actual button is, and where the area of the whole control is.
  4. Add a Debug.WriteLine statement to the Tapped handler so you can see in the output window when it registers a tap.
  5. Run on either Android or iOS... Note that when you tap the button itself, taps are not registered. If you tap on the background area of the TabButton, the handler will fire.

SillyBottomTabsPage-CodeBehind SillyBottomTabsPage-Xaml

Exceptions (if applicable) N/A

Screenshots (if applicable) TapsOnlyWorkOnBackground

jbachelor commented 4 years ago

Here is a quick video demonstrating the issue - Watch the debug output in Visual Studio as I tap the center tab button vs. tapping on the background area. Background area taps are handled by the TapGestureRecognizer (debug output from the code-behind of SillyBottomTabsPage.xaml), and taps on the button itself are handled by the command wired up to the ViewModel (SillyBottomTabsPageViewModel.cs).

https://drive.google.com/open?id=1XGIBPTiaEnsJIT8ckdp66M35lqccAMAz

jbachelor commented 4 years ago

Here is the version of the "SillyCompany.Mobile.Practices" app used to take the video from my previous comment. Please do not hesitate to let me know if you have any questions at all.

https://drive.google.com/open?id=1Re1P_5zx55W-1DElQykL-94qbv55RL1G

Thank you again for your hard work on Sharpnado!

roubachof commented 4 years ago

Thank you for the extensive informations, I will fix this in the next release.

jbachelor commented 4 years ago

Thank you so much... If I can be of any assistance, please let me know!

roubachof commented 4 years ago

A clicked event will be added in version 1.4.