Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MacCatalyst] Implement PointerPressed and PointerReleased (#16925)
- Loading branch information
1 parent
01afe33
commit 6b32433
Showing
3 changed files
with
172 additions
and
102 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
43 changes: 0 additions & 43 deletions
43
src/Controls/src/Core/Platform/iOS/CustomHoverGestureRecognizer.cs
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
src/Controls/src/Core/Platform/iOS/CustomPressGestureRecognizer.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,58 @@ | ||
#nullable disable | ||
using System; | ||
using Foundation; | ||
using ObjCRuntime; | ||
using UIKit; | ||
using PreserveAttribute = Microsoft.Maui.Controls.Internals.PreserveAttribute; | ||
|
||
namespace Microsoft.Maui.Controls.Platform.iOS; | ||
|
||
internal class CustomPressGestureRecognizer : UIGestureRecognizer | ||
{ | ||
NSObject _target; | ||
|
||
public CustomPressGestureRecognizer(NSObject target, Selector action) : base(target, action) | ||
{ | ||
_target = target; | ||
} | ||
|
||
public CustomPressGestureRecognizer(Action<UIGestureRecognizer> action) | ||
: this(new Callback(action), Selector.FromHandle(Selector.GetHandle("target:"))!) { } | ||
|
||
[Register("__UIGestureRecognizer")] | ||
class Callback : Token | ||
{ | ||
Action<UIGestureRecognizer> action; | ||
|
||
internal Callback(Action<UIGestureRecognizer> action) | ||
{ | ||
this.action = action; | ||
} | ||
|
||
[Export("target:")] | ||
[Preserve(Conditional = true)] | ||
public void Activated(UIGestureRecognizer sender) | ||
{ | ||
if (OperatingSystem.IsIOSVersionAtLeast(13)) | ||
action(sender); | ||
} | ||
} | ||
|
||
public override void TouchesBegan(NSSet touches, UIEvent evt) | ||
{ | ||
State = UIGestureRecognizerState.Began; | ||
base.TouchesBegan(touches, evt); | ||
} | ||
|
||
public override void TouchesEnded(NSSet touches, UIEvent evt) | ||
{ | ||
State = UIGestureRecognizerState.Ended; | ||
base.TouchesEnded(touches, evt); | ||
} | ||
|
||
public override void TouchesMoved(NSSet touches, UIEvent evt) | ||
{ | ||
State = UIGestureRecognizerState.Changed; | ||
base.TouchesMoved(touches, evt); | ||
} | ||
} |