Skip to content

Commit

Permalink
Support PointerGestureRecognizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamescaper committed Nov 10, 2024
1 parent b66a4dd commit 533a2b5
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
100 changes: 100 additions & 0 deletions src/BlazorBindings.Maui/Elements/PointerGestureRecognizer.generated.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// <auto-generated>
// This code was generated by a BlazorBindings.Maui component generator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using BlazorBindings.Core;
using MC = Microsoft.Maui.Controls;
using Microsoft.AspNetCore.Components;
using System.Threading.Tasks;

#pragma warning disable MBB001

namespace BlazorBindings.Maui.Elements
{
/// <summary>
/// Provides pointer gesture recognition and events.
/// </summary>
public partial class PointerGestureRecognizer : GestureRecognizer
{
static PointerGestureRecognizer()
{
RegisterAdditionalHandlers();
}

[Parameter] public EventCallback<MC.PointerEventArgs> OnPointerEntered { get; set; }
[Parameter] public EventCallback<MC.PointerEventArgs> OnPointerExited { get; set; }
[Parameter] public EventCallback<MC.PointerEventArgs> OnPointerMoved { get; set; }
[Parameter] public EventCallback<MC.PointerEventArgs> OnPointerPressed { get; set; }
[Parameter] public EventCallback<MC.PointerEventArgs> OnPointerReleased { get; set; }

public new MC.PointerGestureRecognizer NativeControl => (MC.PointerGestureRecognizer)((BindableObject)this).NativeControl;

protected override MC.PointerGestureRecognizer CreateNativeElement() => new();

protected override void HandleParameter(string name, object value)
{
switch (name)
{
case nameof(OnPointerEntered):
if (!Equals(OnPointerEntered, value))
{
void NativeControlPointerEntered(object sender, MC.PointerEventArgs e) => InvokeEventCallback(OnPointerEntered, e);

OnPointerEntered = (EventCallback<MC.PointerEventArgs>)value;
NativeControl.PointerEntered -= NativeControlPointerEntered;
NativeControl.PointerEntered += NativeControlPointerEntered;
}
break;
case nameof(OnPointerExited):
if (!Equals(OnPointerExited, value))
{
void NativeControlPointerExited(object sender, MC.PointerEventArgs e) => InvokeEventCallback(OnPointerExited, e);

OnPointerExited = (EventCallback<MC.PointerEventArgs>)value;
NativeControl.PointerExited -= NativeControlPointerExited;
NativeControl.PointerExited += NativeControlPointerExited;
}
break;
case nameof(OnPointerMoved):
if (!Equals(OnPointerMoved, value))
{
void NativeControlPointerMoved(object sender, MC.PointerEventArgs e) => InvokeEventCallback(OnPointerMoved, e);

OnPointerMoved = (EventCallback<MC.PointerEventArgs>)value;
NativeControl.PointerMoved -= NativeControlPointerMoved;
NativeControl.PointerMoved += NativeControlPointerMoved;
}
break;
case nameof(OnPointerPressed):
if (!Equals(OnPointerPressed, value))
{
void NativeControlPointerPressed(object sender, MC.PointerEventArgs e) => InvokeEventCallback(OnPointerPressed, e);

OnPointerPressed = (EventCallback<MC.PointerEventArgs>)value;
NativeControl.PointerPressed -= NativeControlPointerPressed;
NativeControl.PointerPressed += NativeControlPointerPressed;
}
break;
case nameof(OnPointerReleased):
if (!Equals(OnPointerReleased, value))
{
void NativeControlPointerReleased(object sender, MC.PointerEventArgs e) => InvokeEventCallback(OnPointerReleased, e);

OnPointerReleased = (EventCallback<MC.PointerEventArgs>)value;
NativeControl.PointerReleased -= NativeControlPointerReleased;
NativeControl.PointerReleased += NativeControlPointerReleased;
}
break;

default:
base.HandleParameter(name, value);
break;
}
}

static partial void RegisterAdditionalHandlers();
}
}
1 change: 1 addition & 0 deletions src/BlazorBindings.Maui/Properties/AttributeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
[assembly: GenerateComponent(typeof(PinchGestureRecognizer))]
[assembly: GenerateComponent(typeof(SwipeGestureRecognizer))]
[assembly: GenerateComponent(typeof(TapGestureRecognizer))]
[assembly: GenerateComponent(typeof(PointerGestureRecognizer))]


// Compatibility
Expand Down

0 comments on commit 533a2b5

Please sign in to comment.