Made browser refresh functionality respect the configured settings.
This commit is contained in:
		
							parent
							
								
									12246bd0f5
								
							
						
					
					
						commit
						cbb3e797b0
					
				
					 2 changed files with 16 additions and 3 deletions
				
			
		|  | @ -71,7 +71,7 @@ namespace SafeExamBrowser.Browser | ||||||
| 			TitleChanged += (o, args) => titleChanged?.Invoke(args.Title); | 			TitleChanged += (o, args) => titleChanged?.Invoke(args.Title); | ||||||
| 
 | 
 | ||||||
| 			MenuHandler = new BrowserContextMenuHandler(settings, text); | 			MenuHandler = new BrowserContextMenuHandler(settings, text); | ||||||
| 			KeyboardHandler = new BrowserKeyboardHandler(); | 			KeyboardHandler = new BrowserKeyboardHandler(settings); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -8,11 +8,22 @@ | ||||||
| 
 | 
 | ||||||
| using System.Windows.Forms; | using System.Windows.Forms; | ||||||
| using CefSharp; | using CefSharp; | ||||||
|  | using IBrowserSettings = SafeExamBrowser.Contracts.Configuration.Settings.IBrowserSettings; | ||||||
| 
 | 
 | ||||||
| namespace SafeExamBrowser.Browser.Handlers | namespace SafeExamBrowser.Browser.Handlers | ||||||
| { | { | ||||||
| 	class BrowserKeyboardHandler : IKeyboardHandler | 	/// <remarks> | ||||||
|  | 	/// See https://cefsharp.github.io/api/57.0.0/html/T_CefSharp_IKeyboardHandler.htm. | ||||||
|  | 	/// </remarks> | ||||||
|  | 	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) | 		public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey) | ||||||
| 		{ | 		{ | ||||||
| 			return false; | 			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) | 		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(); | 				browserControl.Reload(); | ||||||
|  | 
 | ||||||
|  | 				return true; | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			return false; | 			return false; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 dbuechel
						dbuechel