mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Hook copy command
This commit is contained in:
parent
9d94507e16
commit
6f556a47b5
3 changed files with 13 additions and 26 deletions
|
|
@ -178,6 +178,9 @@
|
|||
Style="{DynamicResource QueryBoxStyle}"
|
||||
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Visibility="Visible">
|
||||
<TextBox.CommandBindings>
|
||||
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
|
||||
</TextBox.CommandBindings>
|
||||
<TextBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Command="ApplicationCommands.Cut" />
|
||||
|
|
|
|||
|
|
@ -47,7 +47,17 @@ namespace Flow.Launcher
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void OnCopy(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
var results = _viewModel.Results;
|
||||
var result = results.SelectedItem?.Result;
|
||||
if (result != null) // SelectedItem returns null if selection is empty.
|
||||
{
|
||||
|
||||
System.Windows.Clipboard.SetDataObject(result.Title.ToString());
|
||||
}
|
||||
e.Handled = true;
|
||||
}
|
||||
private async void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
_settings.WindowTop = Top;
|
||||
|
|
|
|||
|
|
@ -189,32 +189,6 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult());
|
||||
|
||||
CopyToClipboard = new RelayCommand(index =>
|
||||
{
|
||||
var results = SelectedResults;
|
||||
|
||||
if (index != null)
|
||||
{
|
||||
results.SelectedIndex = int.Parse(index.ToString());
|
||||
}
|
||||
|
||||
var result = results.SelectedItem?.Result;
|
||||
if (result != null) // SelectedItem returns null if selection is empty.
|
||||
{
|
||||
bool hideWindow = result.Action != null && result.Action(new ActionContext
|
||||
{
|
||||
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
|
||||
});
|
||||
Clipboard.SetText(result.Title.ToString());
|
||||
if (hideWindow)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
StartHelpCommand = new RelayCommand(_ =>
|
||||
{
|
||||
SearchWeb.NewTabInBrowser("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/");
|
||||
|
|
|
|||
Loading…
Reference in a new issue