Allow enter key in settings textbox to connect

This commit is contained in:
Théo Marchal 2021-10-04 19:13:25 +02:00
parent e4b63073d8
commit 72d751db71
3 changed files with 8 additions and 4 deletions

View File

@ -162,9 +162,7 @@ namespace unison
private void SearchHandler(object sender, KeyEventArgs e) private void SearchHandler(object sender, KeyEventArgs e)
{ {
if (e.Key == Key.Return) if (e.Key == Key.Return)
{
Search_Clicked(null, null); Search_Clicked(null, null);
}
} }
private void Window_Closing(object sender, CancelEventArgs e) private void Window_Closing(object sender, CancelEventArgs e)

View File

@ -25,12 +25,12 @@
<StackPanel> <StackPanel>
<StackPanel> <StackPanel>
<TextBlock Text="{x:Static properties:Resources.Settings_Host}" TextWrapping="Wrap" Margin="5,0,0,0"/> <TextBlock Text="{x:Static properties:Resources.Settings_Host}" TextWrapping="Wrap" Margin="5,0,0,0"/>
<TextBox x:Name="MpdHost" TextWrapping="Wrap" Width="250" Margin="10,2,0,0"/> <TextBox x:Name="MpdHost" KeyDown="ConnectHandler" TextWrapping="Wrap" Width="250" Margin="10,2,0,0"/>
</StackPanel> </StackPanel>
<StackPanel Margin="0,5,0,0"> <StackPanel Margin="0,5,0,0">
<TextBlock Text="{x:Static properties:Resources.Settings_Port}" TextWrapping="Wrap" Margin="5,0,0,0"/> <TextBlock Text="{x:Static properties:Resources.Settings_Port}" TextWrapping="Wrap" Margin="5,0,0,0"/>
<TextBox x:Name="MpdPort" MaxLength="5" PreviewTextInput="NumberValidationTextBox" TextWrapping="Wrap" Width="250" Margin="10,2,0,0"/> <TextBox x:Name="MpdPort" KeyDown="ConnectHandler" MaxLength="5" PreviewTextInput="NumberValidationTextBox" TextWrapping="Wrap" Width="250" Margin="10,2,0,0"/>
</StackPanel> </StackPanel>
<!--<StackPanel Margin="0,5,0,0"> <!--<StackPanel Margin="0,5,0,0">

View File

@ -101,6 +101,12 @@ namespace unison
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
} }
private void ConnectHandler(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
MPDConnect_Clicked(null, null);
}
private void Window_Closing(object sender, CancelEventArgs e) private void Window_Closing(object sender, CancelEventArgs e)
{ {
e.Cancel = true; e.Cancel = true;