diff --git a/SafeExamBrowser.Browser/BrowserControl.cs b/SafeExamBrowser.Browser/BrowserControl.cs index 604f38a0..9efdd5d4 100644 --- a/SafeExamBrowser.Browser/BrowserControl.cs +++ b/SafeExamBrowser.Browser/BrowserControl.cs @@ -71,7 +71,7 @@ namespace SafeExamBrowser.Browser TitleChanged += (o, args) => titleChanged?.Invoke(args.Title); MenuHandler = new BrowserContextMenuHandler(settings, text); - KeyboardHandler = new BrowserKeyboardHandler(); + KeyboardHandler = new BrowserKeyboardHandler(settings); } } } diff --git a/SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs b/SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs index 10a739a3..81cd675f 100644 --- a/SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/BrowserKeyboardHandler.cs @@ -8,11 +8,22 @@ using System.Windows.Forms; using CefSharp; +using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings; namespace SafeExamBrowser.Browser.Handlers { - class BrowserKeyboardHandler : IKeyboardHandler + /// + /// See https://cefsharp.github.io/api/57.0.0/html/T_CefSharp_IKeyboardHandler.htm. + /// + internal class BrowserKeyboardHandler : IKeyboardHandler { + private IBrowserSettings settings; + + public BrowserKeyboardHandler(IBrowserSettings settings) + { + this.settings = settings; + } + public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey) { return false; @@ -20,9 +31,11 @@ namespace SafeExamBrowser.Browser.Handlers public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut) { - if (type == KeyType.KeyUp && windowsKeyCode == (int) Keys.F5) + if (settings.AllowReloading && type == KeyType.KeyUp && windowsKeyCode == (int) Keys.F5) { browserControl.Reload(); + + return true; } return false;