-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] TapGestureRecognizer should not fire when view is not enabled (#…
…23049) * Don't receive touch when view is disabled * Add UITest for Single Tap enabled/disabled This removes the first pass unit test version which isn't really testing the scenario properly. * Fix element automation id * Don't fire tap for windows if control disabled * Make failure case text less confusing
- Loading branch information
Showing
5 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/Controls/tests/TestCases/Elements/TapGestureGallery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace Maui.Controls.Sample | ||
{ | ||
public class SingleTapGallery : Microsoft.Maui.Controls.ContentView | ||
{ | ||
public SingleTapGallery() | ||
{ | ||
AutomationId = nameof(SingleTapGallery); | ||
|
||
var layout = new VerticalStackLayout { Margin = 10, Spacing = 10 }; | ||
|
||
var singleTapResults = new Label { AutomationId = "SingleTapGestureResults", Text = "Should succeed."}; | ||
var singleTapSurface = new Grid() | ||
{ | ||
HeightRequest = 100, | ||
WidthRequest = 200, | ||
BackgroundColor = Microsoft.Maui.Graphics.Colors.AliceBlue, | ||
Children = { new Label { Text = "SingleTapSurface", AutomationId = "SingleTapSurface" } } | ||
}; | ||
|
||
var singleTapRecognizer = new TapGestureRecognizer(); | ||
singleTapRecognizer.Tapped += (sender, args) => { singleTapResults.Text = "Success"; }; | ||
singleTapSurface.GestureRecognizers.Add(singleTapRecognizer); | ||
|
||
layout.Add(singleTapSurface); | ||
layout.Add(singleTapResults); | ||
|
||
|
||
// Now add a tap surface that is disabled and a results label that should not change when the surface is tapped | ||
var disabledTapResults = new Label { AutomationId = "DisabledTapGestureResults", Text = "Should not change when tapped" }; | ||
var disabledTapSurface = new Grid() | ||
{ | ||
IsEnabled = false, // Disabled | ||
HeightRequest = 100, | ||
WidthRequest = 200, | ||
BackgroundColor = Microsoft.Maui.Graphics.Colors.Bisque, | ||
Children = { new Label { Text = "DisabledTapSurface", AutomationId = "DisabledTapSurface" } } | ||
}; | ||
|
||
// Wire up the tap gesture recognizer, it should never fire | ||
var disabledTapRecognizer = new TapGestureRecognizer(); | ||
disabledTapRecognizer.Tapped += (sender, args) => { disabledTapResults.Text = "Failed"; }; | ||
disabledTapSurface.GestureRecognizers.Add(disabledTapRecognizer); | ||
|
||
layout.Add(disabledTapSurface); | ||
layout.Add(disabledTapResults); | ||
|
||
Content = layout; | ||
} | ||
} | ||
} |