diff --git a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs index ef17c798..a945bab5 100644 --- a/SafeExamBrowser.Browser/BrowserApplicationInstance.cs +++ b/SafeExamBrowser.Browser/BrowserApplicationInstance.cs @@ -217,6 +217,7 @@ namespace SafeExamBrowser.Browser window.ZoomResetRequested += ZoomResetRequested; window.UpdateZoomLevel(CalculateZoomPercentage()); window.Show(); + window.BringToForeground(); Handle = window.Handle; diff --git a/SafeExamBrowser.Browser/BrowserControl.cs b/SafeExamBrowser.Browser/BrowserControl.cs index f76c60b3..e9c539f3 100644 --- a/SafeExamBrowser.Browser/BrowserControl.cs +++ b/SafeExamBrowser.Browser/BrowserControl.cs @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; using CefSharp; using CefSharp.WinForms; using SafeExamBrowser.UserInterface.Contracts.Browser; @@ -85,6 +86,7 @@ namespace SafeExamBrowser.Browser public void Initialize() { AddressChanged += (o, args) => addressChanged?.Invoke(args.Address); + IsBrowserInitializedChanged += BrowserControl_IsBrowserInitializedChanged; LoadError += BrowserControl_LoadError; LoadingStateChanged += (o, args) => loadingStateChanged?.Invoke(args.IsLoading); TitleChanged += (o, args) => titleChanged?.Invoke(args.Title); @@ -133,6 +135,14 @@ namespace SafeExamBrowser.Browser GetBrowser().SetZoomLevel(level); } + private void BrowserControl_IsBrowserInitializedChanged(object sender, EventArgs e) + { + if (IsBrowserInitialized) + { + GetBrowser().GetHost().SetFocus(true); + } + } + private void BrowserControl_LoadError(object sender, LoadErrorEventArgs e) { loadFailed?.Invoke((int) e.ErrorCode, e.ErrorText, e.FailedUrl);