From 9cbb510c48719a39a4d3158296d5138d0f461cff Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Mon, 2 May 2022 16:43:50 +0200 Subject: [PATCH] add TabPressedEventHandler.cs --- .../Events/TabPressedEventHandler.cs | 15 +++++++++++++++ .../SafeExamBrowser.Browser.Contracts.csproj | 1 + SafeExamBrowser.Browser/BrowserWindow.cs | 2 +- .../Handlers/KeyboardHandler.cs | 5 +++-- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 SafeExamBrowser.Browser.Contracts/Events/TabPressedEventHandler.cs diff --git a/SafeExamBrowser.Browser.Contracts/Events/TabPressedEventHandler.cs b/SafeExamBrowser.Browser.Contracts/Events/TabPressedEventHandler.cs new file mode 100644 index 00000000..f9586a6c --- /dev/null +++ b/SafeExamBrowser.Browser.Contracts/Events/TabPressedEventHandler.cs @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2022 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +namespace SafeExamBrowser.Browser.Contracts.Events +{ + /// + /// Event handler used to indicate that the user pressed the tab key to move the focus forward or backward. + /// + public delegate void TabPressedEventHandler(bool forward); +} diff --git a/SafeExamBrowser.Browser.Contracts/SafeExamBrowser.Browser.Contracts.csproj b/SafeExamBrowser.Browser.Contracts/SafeExamBrowser.Browser.Contracts.csproj index 7404735e..02460564 100644 --- a/SafeExamBrowser.Browser.Contracts/SafeExamBrowser.Browser.Contracts.csproj +++ b/SafeExamBrowser.Browser.Contracts/SafeExamBrowser.Browser.Contracts.csproj @@ -57,6 +57,7 @@ + diff --git a/SafeExamBrowser.Browser/BrowserWindow.cs b/SafeExamBrowser.Browser/BrowserWindow.cs index 53ce3aba..bf94af95 100644 --- a/SafeExamBrowser.Browser/BrowserWindow.cs +++ b/SafeExamBrowser.Browser/BrowserWindow.cs @@ -702,7 +702,7 @@ namespace SafeExamBrowser.Browser } } - private void TabPressed(object sender, bool shiftPressed) + private void TabPressed(bool shiftPressed) { this.Control.ExecuteJavascript("document.activeElement.tagName", result => { diff --git a/SafeExamBrowser.Browser/Handlers/KeyboardHandler.cs b/SafeExamBrowser.Browser/Handlers/KeyboardHandler.cs index e7b48563..aae93188 100644 --- a/SafeExamBrowser.Browser/Handlers/KeyboardHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/KeyboardHandler.cs @@ -8,6 +8,7 @@ using System.Windows.Forms; using CefSharp; +using SafeExamBrowser.Browser.Contracts.Events; using SafeExamBrowser.UserInterface.Contracts; namespace SafeExamBrowser.Browser.Handlers @@ -21,7 +22,7 @@ namespace SafeExamBrowser.Browser.Handlers internal event ActionRequestedEventHandler ZoomOutRequested; internal event ActionRequestedEventHandler ZoomResetRequested; internal event ActionRequestedEventHandler FocusAddressBarRequested; - internal event System.EventHandler TabPressed; + internal event TabPressedEventHandler TabPressed; private int? currentKeyDown = null; @@ -64,7 +65,7 @@ namespace SafeExamBrowser.Browser.Handlers if (keyCode == (int)Keys.Tab && keyCode == currentKeyDown) { - TabPressed?.Invoke(this, shift); + TabPressed?.Invoke(shift); } }