From 7c3fddd0600e7dbde29cab699d8d725cc068f115 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Wed, 2 Aug 2017 07:57:57 +0200 Subject: [PATCH] Made address bar of browser window react on enter key. --- .../BrowserWindow.xaml | 2 +- .../BrowserWindow.xaml.cs | 24 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/SafeExamBrowser.UserInterface/BrowserWindow.xaml b/SafeExamBrowser.UserInterface/BrowserWindow.xaml index 57f6697b..18fb1c70 100644 --- a/SafeExamBrowser.UserInterface/BrowserWindow.xaml +++ b/SafeExamBrowser.UserInterface/BrowserWindow.xaml @@ -18,7 +18,7 @@ - + diff --git a/SafeExamBrowser.UserInterface/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface/BrowserWindow.xaml.cs index 4d9efea8..214e7cbe 100644 --- a/SafeExamBrowser.UserInterface/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface/BrowserWindow.xaml.cs @@ -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)