From 6dbcdfea47e60aadefd59a75e43549793481f853 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Sun, 16 Apr 2023 09:09:02 +0200 Subject: Ava: Fix nca extraction window never closing & minor cleanup (#4569) * ava: Remove unused doWhileDeferred parameters * ava: Minimally improve swkbd dialog It's currently impossible to get the dialog to redirect focus to the InputBox. * ava: Fix nca extraction dialog never closing Also contains some minor cleanup --- Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml | 3 +- Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml.cs | 45 +++++------------------- 2 files changed, 10 insertions(+), 38 deletions(-) (limited to 'Ryujinx.Ava/UI/Applet') diff --git a/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml b/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml index 43ccf9e7..65504569 100644 --- a/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml +++ b/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml @@ -48,6 +48,7 @@ Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" + Focusable="True" KeyUp="Message_KeyUp" Text="{Binding Message}" TextInput="Message_TextInput" @@ -61,4 +62,4 @@ HorizontalAlignment="Stretch" TextWrapping="Wrap" /> - \ No newline at end of file + diff --git a/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml.cs b/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml.cs index fb689ec2..cb69e96b 100644 --- a/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml.cs +++ b/Ryujinx.Ava/UI/Applet/SwkbdAppletDialog.axaml.cs @@ -45,6 +45,13 @@ namespace Ryujinx.Ava.UI.Controls InitializeComponent(); } + protected override void OnGotFocus(GotFocusEventArgs e) + { + // FIXME: This does not work. Might be a bug in Avalonia with DialogHost + // Currently focus will be redirected to the overlay window instead. + Input.Focus(); + } + public string Message { get; set; } = ""; public string MainText { get; set; } = ""; public string SecondaryText { get; set; } = ""; @@ -59,24 +66,6 @@ namespace Ryujinx.Ava.UI.Controls string input = string.Empty; - var overlay = new ContentDialogOverlayWindow() - { - Height = window.Bounds.Height, - Width = window.Bounds.Width, - Position = window.PointToScreen(new Point()) - }; - - window.PositionChanged += OverlayOnPositionChanged; - - void OverlayOnPositionChanged(object sender, PixelPointEventArgs e) - { - overlay.Position = window.PointToScreen(new Point()); - } - - contentDialog = overlay.ContentDialog; - - bool opened = false; - content.SetInputLengthValidation(args.StringLengthMin, args.StringLengthMax); content._host = contentDialog; @@ -97,25 +86,7 @@ namespace Ryujinx.Ava.UI.Controls }; contentDialog.Closed += handler; - overlay.Opened += OverlayOnActivated; - - async void OverlayOnActivated(object sender, EventArgs e) - { - if (opened) - { - return; - } - - opened = true; - - overlay.Position = window.PointToScreen(new Point()); - - await contentDialog.ShowAsync(overlay); - contentDialog.Closed -= handler; - overlay.Close(); - }; - - await overlay.ShowDialog(window); + await ContentDialogHelper.ShowAsync(contentDialog); return (result, input); } -- cgit v1.2.3