mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 06:29:44 +08:00
Added callback function for mouse click on search result
This commit is contained in:
parent
d73ab36dc3
commit
b6f927c454
@ -418,7 +418,7 @@
|
||||
|
||||
|
||||
<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>
|
||||
<SymbolIcon Symbol="Find"/>
|
||||
</AutoSuggestBox.QueryIcon>
|
||||
|
@ -18,6 +18,7 @@ using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace PowerLauncher
|
||||
{
|
||||
@ -133,6 +134,8 @@ namespace PowerLauncher
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
private void OnDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
@ -256,7 +259,7 @@ namespace PowerLauncher
|
||||
_launcher = (PowerLauncher.UI.LauncherControl)host.Child;
|
||||
_launcher.DataContext = _viewModel;
|
||||
_launcher.SearchBox.TextChanged += QueryTextBox_TextChanged;
|
||||
|
||||
_launcher.SearchBox.SuggestionChosen += SearchBox_SuggestionChosen;
|
||||
_launcher.SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
|
||||
|
||||
_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)
|
||||
{
|
||||
if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
|
||||
|
@ -66,6 +66,5 @@ namespace Wox.ViewModel
|
||||
{
|
||||
return Result.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user