Made address bar of browser window react on enter key.

This commit is contained in:
dbuechel 2017-08-02 07:57:57 +02:00
parent 5c365f02b0
commit 7c3fddd060
2 changed files with 12 additions and 14 deletions

View file

@ -18,7 +18,7 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" x:Name="UrlTextBox" Margin="5,5,2.5,5" Height="20" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
<TextBox Grid.Column="0" x:Name="UrlTextBox" Margin="5,5,2.5,5" Height="20" HorizontalAlignment="Stretch" VerticalContentAlignment="Center" />
<Button Grid.Column="1" x:Name="ReloadButton" Margin="2.5,5,2.5,5" HorizontalAlignment="Center" VerticalAlignment="Center">Reload</Button>
<Button Grid.Column="2" x:Name="BackButton" Margin="2.5,5,2.5,5" HorizontalAlignment="Center" VerticalAlignment="Center">Back</Button>
<Button Grid.Column="3" x:Name="ForwardButton" Margin="2.5,5,5,5" HorizontalAlignment="Center" VerticalAlignment="Center">Forward</Button>

View file

@ -7,7 +7,7 @@
*/
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using SafeExamBrowser.Contracts.Configuration.Settings;
using SafeExamBrowser.Contracts.UserInterface;
@ -63,12 +63,7 @@ namespace SafeExamBrowser.UserInterface
public void UpdateAddress(string url)
{
Dispatcher.Invoke(() =>
{
UrlTextBox.TextChanged -= UrlTextBox_TextChanged;
UrlTextBox.Text = url;
UrlTextBox.TextChanged += UrlTextBox_TextChanged;
});
Dispatcher.Invoke(() => UrlTextBox.Text = url);
}
public void UpdateTitle(string title)
@ -76,11 +71,6 @@ namespace SafeExamBrowser.UserInterface
Dispatcher.Invoke(() => Title = title);
}
private void UrlTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
AddressChanged?.Invoke(UrlTextBox.Text);
}
private void InitializeBrowserWindow(IBrowserControl browserControl)
{
if (browserControl is System.Windows.Forms.Control)
@ -89,7 +79,7 @@ namespace SafeExamBrowser.UserInterface
}
Closing += (o, args) => closing?.Invoke();
UrlTextBox.TextChanged += UrlTextBox_TextChanged;
UrlTextBox.KeyUp += UrlTextBox_KeyUp;
ReloadButton.Click += (o, args) => ReloadRequested?.Invoke();
BackButton.Click += (o, args) => BackwardNavigationRequested?.Invoke();
ForwardButton.Click += (o, args) => ForwardNavigationRequested?.Invoke();
@ -97,6 +87,14 @@ namespace SafeExamBrowser.UserInterface
ApplySettings();
}
private void UrlTextBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
AddressChanged?.Invoke(UrlTextBox.Text);
}
}
private void ApplySettings()
{
if (IsMainWindow && settings.FullScreenMode)