mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
Added callback function for mouse click on search result
This commit is contained in:
@@ -418,7 +418,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<AutoSuggestBox x:Name="SearchBox" x:FieldModifier="public" PlaceholderText="Launch an app" FontSize="24" Style="{StaticResource CustomStyledAutoSuggestBox}" MinWidth="720"
|
<AutoSuggestBox x:Name="SearchBox" x:FieldModifier="public" PlaceholderText="Launch an app" FontSize="24" Style="{StaticResource CustomStyledAutoSuggestBox}" MinWidth="720"
|
||||||
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Results.Results}">
|
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Results.Results}">
|
||||||
<AutoSuggestBox.QueryIcon>
|
<AutoSuggestBox.QueryIcon>
|
||||||
<SymbolIcon Symbol="Find"/>
|
<SymbolIcon Symbol="Find"/>
|
||||||
</AutoSuggestBox.QueryIcon>
|
</AutoSuggestBox.QueryIcon>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
|||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace PowerLauncher
|
namespace PowerLauncher
|
||||||
{
|
{
|
||||||
@@ -134,6 +135,8 @@ namespace PowerLauncher
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void OnDrop(object sender, DragEventArgs e)
|
private void OnDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||||
@@ -256,7 +259,7 @@ namespace PowerLauncher
|
|||||||
_launcher = (PowerLauncher.UI.LauncherControl)host.Child;
|
_launcher = (PowerLauncher.UI.LauncherControl)host.Child;
|
||||||
_launcher.DataContext = _viewModel;
|
_launcher.DataContext = _viewModel;
|
||||||
_launcher.SearchBox.TextChanged += QueryTextBox_TextChanged;
|
_launcher.SearchBox.TextChanged += QueryTextBox_TextChanged;
|
||||||
|
_launcher.SearchBox.SuggestionChosen += SearchBox_SuggestionChosen;
|
||||||
_launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
|
_launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
|
||||||
|
|
||||||
_viewModel.PropertyChanged += (o, e) =>
|
_viewModel.PropertyChanged += (o, e) =>
|
||||||
@@ -277,6 +280,16 @@ namespace PowerLauncher
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SearchBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
|
||||||
|
{
|
||||||
|
if (args != null)
|
||||||
|
{
|
||||||
|
ResultViewModel result = (ResultViewModel)args.SelectedItem;
|
||||||
|
Process.Start(result.Result.SubTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void QueryTextBox_TextChanged(Windows.UI.Xaml.Controls.AutoSuggestBox sender, Windows.UI.Xaml.Controls.AutoSuggestBoxTextChangedEventArgs args)
|
private void QueryTextBox_TextChanged(Windows.UI.Xaml.Controls.AutoSuggestBox sender, Windows.UI.Xaml.Controls.AutoSuggestBoxTextChangedEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
||||||
|
|||||||
@@ -66,6 +66,5 @@ namespace Wox.ViewModel
|
|||||||
{
|
{
|
||||||
return Result.ToString();
|
return Result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user