Skip to content

Commit

Permalink
fix: make event call syncronous
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpinedam committed Aug 11, 2022
1 parent 6f76a78 commit 49dbcdf
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/Uno.UI/Controls/Window.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public static class TraceProvider

internal event Action FrameChanged;

private WeakReference<CoreWindow> _owner;
private ICoreWindowEvents _ownerEvents;

/// <summary>
Expand Down Expand Up @@ -108,7 +107,7 @@ public override void PressesBegan(NSSet<UIPress> presses, UIPressesEvent evt)
{
if (_ownerEvents is { })
{
RaiseKeyEvent(_ownerEvents.RaiseKeyDown, args);
_ownerEvents.RaiseKeyDown(args);
handled |= true;
}
}
Expand Down Expand Up @@ -157,15 +156,9 @@ public override void PressesBegan(NSSet<UIPress> presses, UIPressesEvent evt)

internal void SetOwner(CoreWindow owner)
{
_owner = new WeakReference<CoreWindow>(owner);
_ownerEvents = (ICoreWindowEvents)owner;
}

internal CoreWindow GetOwner() =>
_owner != null && _owner.TryGetTarget(out var target) && target is { }
? target
: null;

/// <summary>
/// The behavior to use to bring the focused item into view when opening the keyboard.
/// Null means that auto bring into view on keayboard opening is disabled.
Expand All @@ -177,13 +170,6 @@ internal CoreWindow GetOwner() =>
/// </summary>
public int FocusedViewBringIntoViewOnKeyboardOpensPadding { get; set; }

private void RaiseKeyEvent(Action<KeyEventArgs> raisePointerEvent, KeyEventArgs args)
{
_ = GetOwner()?.Dispatcher.RunAsync(
CoreDispatcherPriority.High,
() => raisePointerEvent(args));
}

private void OnApplicationEnteredBackground(object sender, NSNotificationEventArgs e)
{
_focusedView?.EndEditing(true);
Expand Down

0 comments on commit 49dbcdf

Please sign in to comment.