[UIKit] Add Constructor for UIHoverGestureRecognizer (#15837)

Fixes #15335

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
This commit is contained in:
Haritha Mohan 2022-09-21 12:54:10 -07:00 коммит произвёл GitHub
Родитель ed4c89d0d8
Коммит a9c8efa893
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 33 добавлений и 2 удалений

Просмотреть файл

@ -223,6 +223,10 @@ namespace UIKit {
}
public partial class UIHoverGestureRecognizer : UIGestureRecognizer {
public UIHoverGestureRecognizer (Action<UIHoverGestureRecognizer> action) : base (Selector.GetHandle (UIGestureRecognizer.parametrized_selector), new Callback<UIHoverGestureRecognizer>(action)) {}
}
#endif
}

Просмотреть файл

@ -14,6 +14,7 @@ using System.Collections.Generic;
using Foundation;
using UIKit;
using NUnit.Framework;
using System.Threading;
namespace MonoTouchFixtures.UIKit {
@ -89,6 +90,32 @@ namespace MonoTouchFixtures.UIKit {
GC.KeepAlive (list);
}
[Test]
public void GenericCallbackTest ()
{
var didRun = false;
var callbackEvent = new AutoResetEvent (false);
Action<UITapGestureRecognizer> callback = (UITapGestureRecognizer _) => {
didRun = true;
callbackEvent.Set ();
};
using var recognizer = new UITapGestureRecognizer (callback);
// add gesture recognizer to UI view
using UIView view = new UIView ();
view.AddGestureRecognizer (recognizer);
TestRuntime.RunAsync (DateTime.Now.AddSeconds (30), () => {
// change state of gesture recognizer to execute callback
recognizer.State = UIGestureRecognizerState.Changed;
recognizer.State = UIGestureRecognizerState.Ended;
}, () => didRun);
// blocks main thread until event is trigerred
callbackEvent.WaitOne (30000);
Assert.IsTrue (didRun, "didRun");
}
class FinalizerNotifier
{
public Action Action;
@ -102,7 +129,7 @@ namespace MonoTouchFixtures.UIKit {
Action ();
}
}
}
}
} //end of class
} //end of namespace
#endif // !__WATCHOS__