diff --git a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs index 3bd2dec7..54f8e443 100644 --- a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs @@ -16,6 +16,7 @@ public partial class DNSSettingWindow : WindowBase InitializeComponent(); _config = AppManager.Instance.Config; + Loaded += Window_Loaded; btnCancel.Click += (s, e) => this.Close(); ViewModel = new DNSSettingViewModel(UpdateViewHandler); @@ -100,4 +101,9 @@ public partial class DNSSettingWindow : WindowBase { ProcUtils.ProcessStart("https://sing-box.sagernet.org/zh/configuration/dns/"); } + + private void Window_Loaded(object? sender, RoutedEventArgs e) + { + btnCancel.Focus(); + } } diff --git a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs index a9b060fe..974b2823 100644 --- a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs @@ -15,6 +15,7 @@ public partial class FullConfigTemplateWindow : WindowBase this.Close(); ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler); @@ -49,4 +50,8 @@ public partial class FullConfigTemplateWindow : WindowBase HotkeyManager.Instance.IsPause = false; btnCancel.Click += (s, e) => this.Close(); @@ -134,4 +135,8 @@ public partial class GlobalHotkeySettingWindow : WindowBase { InitializeComponent(); + Loaded += Window_Loaded; btnCancel.Click += (s, e) => this.Close(); _config = AppManager.Instance.Config; @@ -209,4 +211,8 @@ public partial class OptionSettingWindow : WindowBase ViewModel.destOverride = clbdestOverride.SelectedItems.Cast().ToList(); } } + private void Window_Loaded(object? sender, RoutedEventArgs e) + { + btnCancel.Focus(); + } } diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs index 1b6dae74..b0ff1e89 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs @@ -17,6 +17,7 @@ public partial class RoutingSettingWindow : WindowBase { InitializeComponent(); + Loaded += Window_Loaded; this.Closing += RoutingSettingWindow_Closing; btnCancel.Click += (s, e) => this.Close(); this.KeyDown += RoutingSettingWindow_KeyDown; @@ -134,4 +135,8 @@ public partial class RoutingSettingWindow : WindowBase } } } + private void Window_Loaded(object? sender, RoutedEventArgs e) + { + btnCancel.Focus(); + } } diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs index 9ff0bcbd..d6702986 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs @@ -1,5 +1,6 @@ using System.Reactive.Disposables; using Avalonia.Controls; +using Avalonia.Input; using Avalonia.Interactivity; using DialogHostAvalonia; using DynamicData; @@ -20,6 +21,7 @@ public partial class SubSettingWindow : WindowBase menuClose.Click += menuClose_Click; this.Closing += SubSettingWindow_Closing; + this.KeyDown += SubSettingWindow_KeyDown; ViewModel = new SubSettingViewModel(UpdateViewHandler); lstSubscription.DoubleTapped += LstSubscription_DoubleTapped; lstSubscription.SelectionChanged += LstSubscription_SelectionChanged; @@ -106,4 +108,12 @@ public partial class SubSettingWindow : WindowBase } } } + + private void SubSettingWindow_KeyDown(object? sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + { + menuClose_Click(null, null); + } + } }