Close window when escape pressed

This commit is contained in:
Koisu 2025-06-25 10:37:01 -07:00
parent f837b2a5d2
commit 8da182dd25
2 changed files with 14 additions and 2 deletions

View file

@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{DynamicResource plugin_explorer_manageactionkeywords_header}"
Title=""
Height="180"
MaxWidth="600"
Background="{DynamicResource PopuBGColor}"

View file

@ -5,6 +5,7 @@ using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Flow.Launcher.Plugin.Explorer.Helper;
namespace Flow.Launcher.Plugin.Explorer.Views
@ -39,6 +40,14 @@ namespace Flow.Launcher.Plugin.Explorer.Views
ShowInTaskbar = false;
RenameTb.Focus();
var window = Window.GetWindow(this);
window.KeyDown += (s, e) =>
{
if (e.Key == Key.Escape)
{
Close();
}
};
}
/// <summary>
@ -55,10 +64,11 @@ namespace Flow.Launcher.Plugin.Explorer.Views
else if (_info is FileInfo info)
{
string properName = Path.GetFileNameWithoutExtension(info.Name);
Application.Current.Dispatcher.Invoke(textBox.Select, DispatcherPriority.Background, textBox.Text.IndexOf(properName), properName.Length );
Application.Current.Dispatcher.Invoke(textBox.Select, DispatcherPriority.Background, textBox.Text.IndexOf(properName), properName.Length);
}
}
private void OnDoneButtonClick(object sender, RoutedEventArgs e)
{
RenameThing.Rename(NewFileName, _info, _api);
@ -79,5 +89,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
e.Handled = true;
}
}
}
}