From 0b9299f88f1e11b79faeb220bd4f10f27e7b1e8b Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Wed, 1 Jun 2022 17:45:03 +0200 Subject: [PATCH 01/12] fix overlay MouseLeave behavior --- .../Windows/BrowserWindow.xaml.cs | 3 +-- .../Windows/BrowserWindow.xaml.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs index 1f8eead6..394ad2c2 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs @@ -477,9 +477,8 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows HomeButton.Click += (o, args) => HomeNavigationRequested?.Invoke(); Loaded += BrowserWindow_Loaded; MenuButton.Click += MenuButton_Click; - MenuButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsMouseOver)); MenuPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - MenuPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsMouseOver)); + MenuPopup.LostFocus += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsKeyboardFocusWithin)); KeyDown += BrowserWindow_KeyDown; KeyUp += BrowserWindow_KeyUp; LocationChanged += (o, args) => { DownloadsPopup.IsOpen = false; MenuPopup.IsOpen = false; }; diff --git a/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs index 7e0f4e29..ab7f641c 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs @@ -473,9 +473,8 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows HomeButton.Click += (o, args) => HomeNavigationRequested?.Invoke(); Loaded += BrowserWindow_Loaded; MenuButton.Click += MenuButton_Click; - MenuButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsMouseOver)); MenuPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - MenuPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsMouseOver)); + MenuPopup.LostFocus += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => MenuPopup.IsOpen = MenuPopup.IsKeyboardFocusWithin)); KeyDown += BrowserWindow_KeyDown; KeyUp += BrowserWindow_KeyUp; LocationChanged += (o, args) => { DownloadsPopup.IsOpen = false; MenuPopup.IsOpen = false; }; From 20a2c1192794debce4a30971706f3801fee77ddc Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Thu, 22 Sep 2022 11:28:33 +0200 Subject: [PATCH 02/12] set tooltip help text for JAWS --- .../Controls/ActionCenter/KeyboardLayoutControl.xaml.cs | 2 ++ .../Controls/Taskbar/KeyboardLayoutControl.xaml.cs | 2 ++ .../Controls/ActionCenter/KeyboardLayoutControl.xaml.cs | 2 ++ .../Controls/Taskbar/KeyboardLayoutControl.xaml.cs | 2 ++ 4 files changed, 8 insertions(+) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs index 24eaedf8..5085b952 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs @@ -7,6 +7,7 @@ */ using System.Threading.Tasks; +using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Media; using SafeExamBrowser.I18n.Contracts; @@ -96,6 +97,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter Text.Text = layout.CultureName; Button.ToolTip = tooltip; + AutomationProperties.SetHelpText(Button, tooltip); } private void Popup_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs index da280d12..29164785 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs @@ -10,6 +10,7 @@ using System; using System.Linq; using System.Threading.Tasks; using System.Windows; +using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Media; @@ -120,6 +121,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar LayoutCultureCode.Text = layout.CultureCode; Button.ToolTip = tooltip; + AutomationProperties.SetHelpText(Button, tooltip); } private void Popup_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs index eeed1afd..6ad9a883 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs @@ -7,6 +7,7 @@ */ using System.Threading.Tasks; +using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Media; using SafeExamBrowser.I18n.Contracts; @@ -96,6 +97,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter Text.Text = layout.CultureName; Button.ToolTip = tooltip; + AutomationProperties.SetHelpText(Button, tooltip); } private void Popup_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs index 091ce98d..5c685e75 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs @@ -10,6 +10,7 @@ using System; using System.Linq; using System.Threading.Tasks; using System.Windows; +using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Media; @@ -120,6 +121,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar LayoutCultureCode.Text = layout.CultureCode; Button.ToolTip = tooltip; + AutomationProperties.SetHelpText(Button, tooltip); } private void Popup_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) From 900115d66ce3def3ce574d24003fdd1a46b4af72 Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Fri, 7 Oct 2022 14:38:31 +0200 Subject: [PATCH 03/12] possible accessibility bugfix to make JAWS read the help texts --- .../ActionCenter/KeyboardLayoutControl.xaml.cs | 2 +- .../Controls/ActionCenter/NetworkControl.xaml.cs | 2 +- .../ActionCenter/PowerSupplyControl.xaml.cs | 2 +- .../Controls/Taskbar/Clock.xaml | 4 ++-- .../Controls/Taskbar/KeyboardLayoutButton.xaml.cs | 2 +- .../Taskbar/KeyboardLayoutControl.xaml.cs | 2 +- .../Controls/Taskbar/NetworkControl.xaml.cs | 2 +- .../Controls/Taskbar/PowerSupplyControl.xaml.cs | 2 +- .../Windows/BrowserWindow.xaml.cs | 15 ++++++++------- .../ActionCenter/KeyboardLayoutControl.xaml.cs | 2 +- .../Controls/ActionCenter/NetworkControl.xaml.cs | 2 +- .../ActionCenter/PowerSupplyControl.xaml.cs | 2 +- .../Controls/Taskbar/Clock.xaml | 4 ++-- .../Controls/Taskbar/KeyboardLayoutButton.xaml.cs | 2 +- .../Taskbar/KeyboardLayoutControl.xaml.cs | 2 +- .../Controls/Taskbar/NetworkControl.xaml.cs | 2 +- .../Controls/Taskbar/PowerSupplyControl.xaml.cs | 2 +- .../Windows/BrowserWindow.xaml.cs | 12 ++++++------ 18 files changed, 32 insertions(+), 31 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs index 5085b952..6cb01f68 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs @@ -97,7 +97,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter Text.Text = layout.CultureName; Button.ToolTip = tooltip; - AutomationProperties.SetHelpText(Button, tooltip); + AutomationProperties.SetName(Button, tooltip); } private void Popup_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs index 4a5beafd..d9f91158 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs @@ -121,7 +121,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter { Button.ToolTip = text; Text.Text = text; - Button.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text); + Button.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text); } private UIElement GetWirelessIcon(int signalStrength) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/PowerSupplyControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/PowerSupplyControl.xaml.cs index 32dfdd95..79dca71f 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/PowerSupplyControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/PowerSupplyControl.xaml.cs @@ -87,7 +87,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter PowerPlug.Visibility = status.IsOnline ? Visibility.Visible : Visibility.Collapsed; Text.Text = tooltip; Warning.Visibility = status.BatteryChargeStatus == BatteryChargeStatus.Critical ? Visibility.Visible : Visibility.Collapsed; - this.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, tooltip); + this.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, tooltip); } private void RenderCharge(double charge, BatteryChargeStatus status) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/Clock.xaml b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/Clock.xaml index 93517d0f..ea23411a 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/Clock.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/Clock.xaml @@ -11,7 +11,7 @@ - - + + diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutButton.xaml.cs index ad74c2fa..18107a60 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutButton.xaml.cs @@ -43,7 +43,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar CultureCodeTextBlock.Text = layout.CultureCode; CultureNameTextBlock.Text = layout.CultureName; LayoutNameTextBlock.Text = layout.LayoutName; - System.Windows.Automation.AutomationProperties.SetHelpText(Button, layout.LayoutName); + System.Windows.Automation.AutomationProperties.SetName(Button, layout.LayoutName); } } } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs index 29164785..145d5d0e 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs @@ -121,7 +121,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar LayoutCultureCode.Text = layout.CultureCode; Button.ToolTip = tooltip; - AutomationProperties.SetHelpText(Button, tooltip); + AutomationProperties.SetName(Button, tooltip); } private void Popup_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs index 3832f57e..3f632594 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs @@ -88,7 +88,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar { WirelessIcon.Child = GetWirelessIcon(network.SignalStrength); Button.ToolTip = text.Get(TextKey.SystemControl_NetworkWirelessConnected).Replace("%%NAME%%", network.Name); - Button.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, Button.ToolTip as string); + Button.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, Button.ToolTip as string); } WirelessNetworksStackPanel.Children.Add(button); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/PowerSupplyControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/PowerSupplyControl.xaml.cs index 7c80bb12..d6059666 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/PowerSupplyControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/PowerSupplyControl.xaml.cs @@ -101,7 +101,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar Button.ToolTip = tooltip; PowerPlug.Visibility = status.IsOnline ? Visibility.Visible : Visibility.Collapsed; Warning.Visibility = status.BatteryChargeStatus == BatteryChargeStatus.Critical ? Visibility.Visible : Visibility.Collapsed; - this.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, tooltip); + this.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, tooltip); } private void RenderCharge(double charge, BatteryChargeStatus status) diff --git a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs index 394ad2c2..1ce456c3 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs @@ -244,8 +244,8 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows Dispatcher.Invoke(() => { ZoomLevel.Text = $"{value}%"; - var zoomButtonHelpText = text.Get(TextKey.BrowserWindow_ZoomLevelReset).Replace("%%ZOOM%%", value.ToString("0")); - ZoomResetButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, zoomButtonHelpText); + var zoomButtonName = text.Get(TextKey.BrowserWindow_ZoomLevelReset).Replace("%%ZOOM%%", value.ToString("0")); + ZoomResetButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, zoomButtonName); }); } @@ -511,7 +511,8 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows var javascript = @" if (typeof __SEB_focusElement === 'undefined') { __SEB_focusElement = function (forward) { - if (!document.body) { return; } + if (!document.body) + return; var items = [].map .call(document.body.querySelectorAll(['input', 'select', 'a[href]', 'textarea', 'button', '[tabindex]']), function(el, i) { return { el, i } }) .filter(function(e) { return e.el.tabIndex >= 0 && !e.el.disabled && e.el.offsetParent; }) @@ -639,13 +640,13 @@ if (typeof __SEB_focusElement === 'undefined') { private void LoadText() { DeveloperConsoleText.Text = text.Get(TextKey.BrowserWindow_DeveloperConsoleMenuItem); - DeveloperConsoleButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text.Get(TextKey.BrowserWindow_DeveloperConsoleMenuItem)); + DeveloperConsoleButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_DeveloperConsoleMenuItem)); FindCaseSensitiveCheckBox.Content = text.Get(TextKey.BrowserWindow_FindCaseSensitive); FindMenuText.Text = text.Get(TextKey.BrowserWindow_FindMenuItem); - FindMenuButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text.Get(TextKey.BrowserWindow_FindMenuItem)); + FindMenuButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_FindMenuItem)); ZoomText.Text = text.Get(TextKey.BrowserWindow_ZoomMenuItem); - ZoomInButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text.Get(TextKey.BrowserWindow_ZoomMenuPlus)); - ZoomOutButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text.Get(TextKey.BrowserWindow_ZoomMenuMinus)); + ZoomInButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_ZoomMenuPlus)); + ZoomOutButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_ZoomMenuMinus)); ReloadButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_ReloadButton)); BackwardButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_BackwardButton)); ForwardButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_ForwardButton)); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs index 6ad9a883..deb405b7 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs @@ -97,7 +97,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter Text.Text = layout.CultureName; Button.ToolTip = tooltip; - AutomationProperties.SetHelpText(Button, tooltip); + AutomationProperties.SetName(Button, tooltip); } private void Popup_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs index 4b50365a..15b4004f 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs @@ -121,7 +121,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter { Button.ToolTip = text; Text.Text = text; - Button.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text); + Button.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text); } private UIElement GetWirelessIcon(int signalStrength) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/PowerSupplyControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/PowerSupplyControl.xaml.cs index 4985f0bb..adedb3c8 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/PowerSupplyControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/PowerSupplyControl.xaml.cs @@ -87,7 +87,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter PowerPlug.Visibility = status.IsOnline ? Visibility.Visible : Visibility.Collapsed; Text.Text = tooltip; Warning.Visibility = status.BatteryChargeStatus == BatteryChargeStatus.Critical ? Visibility.Visible : Visibility.Collapsed; - this.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, tooltip); + this.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, tooltip); } private void RenderCharge(double charge, BatteryChargeStatus status) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/Clock.xaml b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/Clock.xaml index 97aa83ba..0af201b4 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/Clock.xaml +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/Clock.xaml @@ -11,7 +11,7 @@ - - + + diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutButton.xaml.cs index 89f7f336..e71ef817 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutButton.xaml.cs @@ -43,7 +43,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar CultureCodeTextBlock.Text = layout.CultureCode; CultureNameTextBlock.Text = layout.CultureName; LayoutNameTextBlock.Text = layout.LayoutName; - System.Windows.Automation.AutomationProperties.SetHelpText(Button, layout.LayoutName); + System.Windows.Automation.AutomationProperties.SetName(Button, layout.LayoutName); } } } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs index 5c685e75..dc5250d1 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs @@ -121,7 +121,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar LayoutCultureCode.Text = layout.CultureCode; Button.ToolTip = tooltip; - AutomationProperties.SetHelpText(Button, tooltip); + AutomationProperties.SetName(Button, tooltip); } private void Popup_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs index 0c065270..ae2f1aff 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs @@ -88,7 +88,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar { WirelessIcon.Child = GetWirelessIcon(network.SignalStrength); Button.ToolTip = text.Get(TextKey.SystemControl_NetworkWirelessConnected).Replace("%%NAME%%", network.Name); - Button.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, Button.ToolTip as string); + Button.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, Button.ToolTip as string); } WirelessNetworksStackPanel.Children.Add(button); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/PowerSupplyControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/PowerSupplyControl.xaml.cs index a0eae5f1..61f9915a 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/PowerSupplyControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/PowerSupplyControl.xaml.cs @@ -101,7 +101,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar Button.ToolTip = tooltip; PowerPlug.Visibility = status.IsOnline ? Visibility.Visible : Visibility.Collapsed; Warning.Visibility = status.BatteryChargeStatus == BatteryChargeStatus.Critical ? Visibility.Visible : Visibility.Collapsed; - this.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, tooltip); + this.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, tooltip); } private void RenderCharge(double charge, BatteryChargeStatus status) diff --git a/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs index ab7f641c..066317ff 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs @@ -244,8 +244,8 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows Dispatcher.Invoke(() => { ZoomLevel.Text = $"{value}%"; - var zoomButtonHelpText = text.Get(TextKey.BrowserWindow_ZoomLevelReset).Replace("%%ZOOM%%", value.ToString("0")); - ZoomResetButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, zoomButtonHelpText); + var zoomButtonName = text.Get(TextKey.BrowserWindow_ZoomLevelReset).Replace("%%ZOOM%%", value.ToString("0")); + ZoomResetButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, zoomButtonName); }); } @@ -645,13 +645,13 @@ if (typeof __SEB_focusElement === 'undefined') { private void LoadText() { DeveloperConsoleText.Text = text.Get(TextKey.BrowserWindow_DeveloperConsoleMenuItem); - DeveloperConsoleButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text.Get(TextKey.BrowserWindow_DeveloperConsoleMenuItem)); + DeveloperConsoleButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_DeveloperConsoleMenuItem)); FindCaseSensitiveCheckBox.Content = text.Get(TextKey.BrowserWindow_FindCaseSensitive); FindMenuText.Text = text.Get(TextKey.BrowserWindow_FindMenuItem); - FindMenuButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text.Get(TextKey.BrowserWindow_FindMenuItem)); + FindMenuButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_FindMenuItem)); ZoomText.Text = text.Get(TextKey.BrowserWindow_ZoomMenuItem); - ZoomInButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text.Get(TextKey.BrowserWindow_ZoomMenuPlus)); - ZoomOutButton.SetValue(System.Windows.Automation.AutomationProperties.HelpTextProperty, text.Get(TextKey.BrowserWindow_ZoomMenuMinus)); + ZoomInButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_ZoomMenuPlus)); + ZoomOutButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_ZoomMenuMinus)); ReloadButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_ReloadButton)); BackwardButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_BackwardButton)); ForwardButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_ForwardButton)); From 14ef0a2b2a47c1ed1e12e00c537639c2173bfbc6 Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Tue, 8 Nov 2022 11:02:56 +0100 Subject: [PATCH 04/12] work on accessibility --- .../Controls/ActionCenter/ApplicationButton.xaml.cs | 4 +++- .../Controls/ActionCenter/AudioControl.xaml.cs | 9 +++++++-- .../Controls/Taskbar/ApplicationControl.xaml.cs | 1 + .../Controls/Taskbar/AudioControl.xaml.cs | 9 +++++++-- .../Controls/ActionCenter/ApplicationButton.xaml.cs | 4 +++- .../Controls/ActionCenter/AudioControl.xaml.cs | 9 +++++++-- .../Controls/Taskbar/ApplicationControl.xaml.cs | 1 + .../Controls/Taskbar/AudioControl.xaml.cs | 9 +++++++-- 8 files changed, 36 insertions(+), 10 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/ApplicationButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/ApplicationButton.xaml.cs index db252715..3ecd0db4 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/ApplicationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/ApplicationButton.xaml.cs @@ -35,7 +35,9 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter Icon.Content = IconResourceLoader.Load(window?.Icon ?? application.Icon); Text.Text = window?.Title ?? application.Name; Button.Click += (o, args) => Clicked?.Invoke(this, EventArgs.Empty); - Button.ToolTip = window?.Title ?? application.Tooltip; + var tooltip = window?.Title ?? application.Tooltip; + Button.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(Button, tooltip); if (window != null) { diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs index 55f7992c..293491fb 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs @@ -114,6 +114,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter this.muted = muted; Button.ToolTip = info; + System.Windows.Automation.AutomationProperties.SetName(Button, info); Text.Text = info; Volume.ValueChanged -= Volume_ValueChanged; Volume.Value = Math.Round(volume * 100); @@ -121,14 +122,18 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter if (muted) { + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); ButtonIcon.Content = IconResourceLoader.Load(MutedIcon); - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); PopupIcon.Content = IconResourceLoader.Load(MutedIcon); } else { + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); ButtonIcon.Content = LoadIcon(volume); - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); PopupIcon.Content = LoadIcon(volume); } } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/ApplicationControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/ApplicationControl.xaml.cs index eb3c1a31..33f5ec03 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/ApplicationControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/ApplicationControl.xaml.cs @@ -44,6 +44,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar Button.MouseEnter += (o, args) => WindowPopup.IsOpen = WindowStackPanel.Children.Count > 0; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = WindowPopup.IsMouseOver || ActiveBar.IsMouseOver)); Button.ToolTip = application.Tooltip; + System.Windows.Automation.AutomationProperties.SetName(Button, application.Tooltip); WindowPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(WindowPopup_PlacementCallback); WindowPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = IsMouseOver)); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs index 541416ad..8ca165dd 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs @@ -132,19 +132,24 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar this.muted = muted; Button.ToolTip = info; + System.Windows.Automation.AutomationProperties.SetName(Button, info); Volume.ValueChanged -= Volume_ValueChanged; Volume.Value = Math.Round(volume * 100); Volume.ValueChanged += Volume_ValueChanged; if (muted) { - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); PopupIcon.Content = IconResourceLoader.Load(MutedIcon); ButtonIcon.Content = IconResourceLoader.Load(MutedIcon); } else { - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); PopupIcon.Content = LoadIcon(volume); ButtonIcon.Content = LoadIcon(volume); } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/ApplicationButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/ApplicationButton.xaml.cs index aa80dde3..a821822b 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/ApplicationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/ApplicationButton.xaml.cs @@ -35,7 +35,9 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter Icon.Content = IconResourceLoader.Load(window?.Icon ?? application.Icon); Text.Text = window?.Title ?? application.Name; Button.Click += (o, args) => Clicked?.Invoke(this, EventArgs.Empty); - Button.ToolTip = window?.Title ?? application.Tooltip; + var tooltip = window?.Title ?? application.Tooltip; + Button.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(Button, tooltip); if (window != null) { diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs index a8e57a3e..13806e13 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs @@ -113,6 +113,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter this.muted = muted; Button.ToolTip = info; + System.Windows.Automation.AutomationProperties.SetName(Button, info); Text.Text = info; Volume.ValueChanged -= Volume_ValueChanged; Volume.Value = Math.Round(volume * 100); @@ -120,14 +121,18 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter if (muted) { + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); ButtonIcon.Content = IconResourceLoader.Load(MutedIcon); - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); PopupIcon.Content = IconResourceLoader.Load(MutedIcon); } else { + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); ButtonIcon.Content = LoadIcon(volume); - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); PopupIcon.Content = LoadIcon(volume); } } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/ApplicationControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/ApplicationControl.xaml.cs index 195043af..aa85c490 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/ApplicationControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/ApplicationControl.xaml.cs @@ -44,6 +44,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar Button.MouseEnter += (o, args) => WindowPopup.IsOpen = WindowStackPanel.Children.Count > 0; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = WindowPopup.IsMouseOver || ActiveBar.IsMouseOver)); Button.ToolTip = application.Tooltip; + System.Windows.Automation.AutomationProperties.SetName(Button, application.Tooltip); WindowPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(WindowPopup_PlacementCallback); WindowPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = IsMouseOver)); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs index 350f94d5..56aa2475 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs @@ -132,19 +132,24 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar this.muted = muted; Button.ToolTip = info; + System.Windows.Automation.AutomationProperties.SetName(Button, info); Volume.ValueChanged -= Volume_ValueChanged; Volume.Value = Math.Round(volume * 100); Volume.ValueChanged += Volume_ValueChanged; if (muted) { - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceUnmuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); PopupIcon.Content = IconResourceLoader.Load(MutedIcon); ButtonIcon.Content = IconResourceLoader.Load(MutedIcon); } else { - MuteButton.ToolTip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + var tooltip = text.Get(TextKey.SystemControl_AudioDeviceMuteTooltip); + MuteButton.ToolTip = tooltip; + System.Windows.Automation.AutomationProperties.SetName(MuteButton, tooltip); PopupIcon.Content = LoadIcon(volume); ButtonIcon.Content = LoadIcon(volume); } From a0fb74a07ea930b60997d2e060b84a19d2b19281 Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Wed, 25 Jan 2023 10:50:01 +0100 Subject: [PATCH 05/12] work on accessibility --- SafeExamBrowser.I18n.Contracts/TextKey.cs | 4 ++++ SafeExamBrowser.I18n/Data/de.xml | 14 +++++++++++++- SafeExamBrowser.I18n/Data/en.xml | 14 +++++++++++++- SafeExamBrowser.I18n/Data/fr.xml | 14 +++++++++++++- SafeExamBrowser.I18n/Data/it.xml | 14 +++++++++++++- SafeExamBrowser.I18n/Data/zh.xml | 14 +++++++++++++- .../Windows/BrowserWindow.xaml | 2 +- .../Windows/BrowserWindow.xaml.cs | 4 ++++ 8 files changed, 74 insertions(+), 6 deletions(-) diff --git a/SafeExamBrowser.I18n.Contracts/TextKey.cs b/SafeExamBrowser.I18n.Contracts/TextKey.cs index b45a251b..da2ce5a7 100644 --- a/SafeExamBrowser.I18n.Contracts/TextKey.cs +++ b/SafeExamBrowser.I18n.Contracts/TextKey.cs @@ -26,6 +26,7 @@ namespace SafeExamBrowser.I18n.Contracts Browser_PrintNotAllowed, Browser_Tooltip, BrowserWindow_BackwardButton, + BrowserWindow_CloseButton, BrowserWindow_DeveloperConsoleMenuItem, BrowserWindow_Downloading, BrowserWindow_DownloadCancelled, @@ -37,6 +38,9 @@ namespace SafeExamBrowser.I18n.Contracts BrowserWindow_HomeButton, BrowserWindow_MenuButton, BrowserWindow_ReloadButton, + BrowserWindow_SearchNext, + BrowserWindow_SearchPrevious, + BrowserWindow_SearchTextBox, BrowserWindow_UrlTextBox, BrowserWindow_ZoomLevelReset, BrowserWindow_ZoomMenuItem, diff --git a/SafeExamBrowser.I18n/Data/de.xml b/SafeExamBrowser.I18n/Data/de.xml index 2e56014f..f5449e50 100644 --- a/SafeExamBrowser.I18n/Data/de.xml +++ b/SafeExamBrowser.I18n/Data/de.xml @@ -31,7 +31,7 @@ Drucken ist nicht erlaubt gemäss der aktiven Konfiguration. - Browser Applikation + Geöffnete Websites Entwickler-Konsole @@ -69,6 +69,9 @@ Menü + + Schliessen + URL eingeben @@ -84,6 +87,15 @@ Zoom verkleinern + + Text eingeben zum Suchen + + + Nächstes Suchresultat + + + Vorheriges Suchresultat + Build diff --git a/SafeExamBrowser.I18n/Data/en.xml b/SafeExamBrowser.I18n/Data/en.xml index c4c35e5d..df82cb90 100644 --- a/SafeExamBrowser.I18n/Data/en.xml +++ b/SafeExamBrowser.I18n/Data/en.xml @@ -31,7 +31,7 @@ Printing is not allowed according to the current configuration. - Browser Application + Open Webpages Developer Console @@ -69,6 +69,9 @@ Menu + + Close + Enter URL @@ -84,6 +87,15 @@ Decrease Page Zoom + + Enter text to search + + + Next search result + + + Previous search result + Build diff --git a/SafeExamBrowser.I18n/Data/fr.xml b/SafeExamBrowser.I18n/Data/fr.xml index a630e7cd..f0d73ffa 100644 --- a/SafeExamBrowser.I18n/Data/fr.xml +++ b/SafeExamBrowser.I18n/Data/fr.xml @@ -34,7 +34,7 @@ Application du navigateur - Console de développement + Sites web ouverts Chargement… @@ -69,6 +69,9 @@ Menu + + Fermer + Entrer l'URL @@ -84,6 +87,15 @@ Diminuer zoom + + Saisir du texte pour rechercher + + + Résultat de recherche prochain + + + Résultat de recherche précédent + Build diff --git a/SafeExamBrowser.I18n/Data/it.xml b/SafeExamBrowser.I18n/Data/it.xml index c916323b..20fc8a4e 100644 --- a/SafeExamBrowser.I18n/Data/it.xml +++ b/SafeExamBrowser.I18n/Data/it.xml @@ -34,7 +34,7 @@ Applicazione browser - Console di sviluppo + Siti web aperti Download in corso ... @@ -69,6 +69,9 @@ Menu + + Chiudere + Inserisci URL @@ -84,6 +87,15 @@ Diminuire zoom + + Immettere il testo da cercare + + + Risultato della ricerca successiva + + + Risultato della ricerca precedente + Build diff --git a/SafeExamBrowser.I18n/Data/zh.xml b/SafeExamBrowser.I18n/Data/zh.xml index 72cec036..f6f972ca 100644 --- a/SafeExamBrowser.I18n/Data/zh.xml +++ b/SafeExamBrowser.I18n/Data/zh.xml @@ -34,7 +34,7 @@ 根据当前配置不允许打印。 - 浏览器应用程序 + 开放网站 开发者控制台 @@ -66,6 +66,9 @@ 菜单 + + 关闭 + 输入网址 @@ -81,6 +84,15 @@ 减少页面缩放 + + 输入文本进行搜索 + + + 下一个搜索结果 + + + 前一个搜索结果 + 生成 diff --git a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml index cd4b266d..a7a7753b 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml @@ -80,7 +80,7 @@ - diff --git a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs index 1ce456c3..8cea8688 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs @@ -654,6 +654,10 @@ if (typeof __SEB_focusElement === 'undefined') { HomeButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_HomeButton)); MenuButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_MenuButton)); UrlTextBox.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_UrlTextBox)); + FindTextBox.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_SearchTextBox)); + FindPreviousButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_SearchPrevious)); + FindNextButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_SearchNext)); + FindbarCloseButton.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text.Get(TextKey.BrowserWindow_CloseButton)); } } } From 765bfcb516dc9f81262e33cea0ab6390b47d74cf Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Fri, 3 Feb 2023 15:42:22 +0100 Subject: [PATCH 06/12] network button accessibility --- .../Controls/Taskbar/NetworkControl.xaml.cs | 18 ++++++++++++------ .../Controls/Taskbar/NetworkControl.xaml.cs | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs index 3f632594..a38ce91c 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs @@ -87,8 +87,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar if (network.Status == ConnectionStatus.Connected) { WirelessIcon.Child = GetWirelessIcon(network.SignalStrength); - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkWirelessConnected).Replace("%%NAME%%", network.Name); - Button.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, Button.ToolTip as string); + UpdateText(text.Get(TextKey.SystemControl_NetworkWirelessConnected).Replace("%%NAME%%", network.Name)); } WirelessNetworksStackPanel.Children.Add(button); @@ -98,7 +97,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar { case ConnectionType.Wired: Button.IsEnabled = false; - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkWiredConnected); + UpdateText(text.Get(TextKey.SystemControl_NetworkWiredConnected)); WiredIcon.Visibility = Visibility.Visible; WirelessIcon.Visibility = Visibility.Collapsed; break; @@ -109,7 +108,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar break; default: Button.IsEnabled = false; - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkNotAvailable); + UpdateText(text.Get(TextKey.SystemControl_NetworkNotAvailable)); WiredIcon.Visibility = Visibility.Visible; WirelessIcon.Visibility = Visibility.Collapsed; break; @@ -118,19 +117,20 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar switch (adapter.Status) { case ConnectionStatus.Connected: + UpdateText(text.Get(TextKey.SystemControl_NetworkWiredConnected)); NetworkStatusIcon.Rotation = 0; NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Globe, Brushes.Green); NetworkStatusIcon.Spin = false; break; case ConnectionStatus.Connecting: - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkWirelessConnecting); + UpdateText(text.Get(TextKey.SystemControl_NetworkWirelessConnecting)); NetworkStatusIcon.Rotation = 0; NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Cog, Brushes.DimGray); NetworkStatusIcon.Spin = true; NetworkStatusIcon.SpinDuration = 2; break; default: - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkDisconnected); + UpdateText(text.Get(TextKey.SystemControl_NetworkDisconnected)); NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Ban, Brushes.DarkOrange); NetworkStatusIcon.Spin = false; WirelessIcon.Child = GetWirelessIcon(0); @@ -138,6 +138,12 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar } } + private void UpdateText(string text) + { + Button.ToolTip = text; + Button.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text); + } + private UIElement GetWirelessIcon(int signalStrength) { var icon = signalStrength > 66 ? "100" : (signalStrength > 33 ? "66" : (signalStrength > 0 ? "33" : "0")); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs index ae2f1aff..b6bf3067 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs @@ -87,8 +87,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar if (network.Status == ConnectionStatus.Connected) { WirelessIcon.Child = GetWirelessIcon(network.SignalStrength); - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkWirelessConnected).Replace("%%NAME%%", network.Name); - Button.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, Button.ToolTip as string); + UpdateText(text.Get(TextKey.SystemControl_NetworkWirelessConnected).Replace("%%NAME%%", network.Name)); } WirelessNetworksStackPanel.Children.Add(button); @@ -98,7 +97,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar { case ConnectionType.Wired: Button.IsEnabled = false; - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkWiredConnected); + UpdateText(text.Get(TextKey.SystemControl_NetworkWiredConnected)); WiredIcon.Visibility = Visibility.Visible; WirelessIcon.Visibility = Visibility.Collapsed; break; @@ -109,7 +108,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar break; default: Button.IsEnabled = false; - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkNotAvailable); + UpdateText(text.Get(TextKey.SystemControl_NetworkNotAvailable)); WiredIcon.Visibility = Visibility.Visible; WirelessIcon.Visibility = Visibility.Collapsed; break; @@ -118,19 +117,20 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar switch (adapter.Status) { case ConnectionStatus.Connected: + UpdateText(text.Get(TextKey.SystemControl_NetworkWiredConnected)); NetworkStatusIcon.Rotation = 0; NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Globe, Brushes.Green); NetworkStatusIcon.Spin = false; break; case ConnectionStatus.Connecting: - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkWirelessConnecting); + UpdateText(text.Get(TextKey.SystemControl_NetworkWirelessConnecting)); NetworkStatusIcon.Rotation = 0; NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Cog, Brushes.DimGray); NetworkStatusIcon.Spin = true; NetworkStatusIcon.SpinDuration = 2; break; default: - Button.ToolTip = text.Get(TextKey.SystemControl_NetworkDisconnected); + UpdateText(text.Get(TextKey.SystemControl_NetworkDisconnected)); NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Ban, Brushes.DarkOrange); NetworkStatusIcon.Spin = false; WirelessIcon.Child = GetWirelessIcon(0); @@ -138,6 +138,12 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar } } + private void UpdateText(string text) + { + Button.ToolTip = text; + Button.SetValue(System.Windows.Automation.AutomationProperties.NameProperty, text); + } + private UIElement GetWirelessIcon(int signalStrength) { var icon = signalStrength > 66 ? "100" : (signalStrength > 33 ? "66" : (signalStrength > 0 ? "33" : "0")); From 31f5c75a9043b5378636c67bd761a8d305666803 Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Mon, 13 Feb 2023 13:39:53 +0100 Subject: [PATCH 07/12] fix popups space bar problem --- .../ActionCenter/KeyboardLayoutControl.xaml.cs | 18 +++++++++++++++++- .../ActionCenter/NetworkControl.xaml.cs | 17 ++++++++++++++++- .../ActionCenter/RaiseHandControl.xaml.cs | 17 ++++++++++++++++- .../Controls/Taskbar/AudioControl.xaml.cs | 17 ++++++++++++++++- .../Taskbar/KeyboardLayoutControl.xaml.cs | 17 ++++++++++++++++- .../Controls/Taskbar/NetworkControl.xaml.cs | 17 ++++++++++++++++- .../Controls/Taskbar/RaiseHandControl.xaml.cs | 17 ++++++++++++++++- .../Controls/ActionCenter/AudioControl.xaml.cs | 17 ++++++++++++++++- .../ActionCenter/KeyboardLayoutControl.xaml.cs | 18 +++++++++++++++++- .../ActionCenter/NetworkControl.xaml.cs | 17 ++++++++++++++++- .../ActionCenter/RaiseHandControl.xaml.cs | 17 ++++++++++++++++- .../Controls/Taskbar/AudioControl.xaml.cs | 17 ++++++++++++++++- .../Taskbar/KeyboardLayoutControl.xaml.cs | 17 ++++++++++++++++- .../Controls/Taskbar/NetworkControl.xaml.cs | 17 ++++++++++++++++- .../Controls/Taskbar/RaiseHandControl.xaml.cs | 17 ++++++++++++++++- 15 files changed, 242 insertions(+), 15 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs index 6cb01f68..e43d7b5b 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; using System.Threading.Tasks; using System.Windows.Automation; using System.Windows.Controls; @@ -50,7 +51,22 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter LayoutsStackPanel.Children[0].Focus(); })); }; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; Popup.Closed += (o, args) => Grid.Background = originalBrush; diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs index d9f91158..d50efecd 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs @@ -45,7 +45,22 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter adapter.Changed += () => Dispatcher.InvokeAsync(Update); Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; Popup.Closed += (o, args) => Grid.Background = originalBrush; diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/RaiseHandControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/RaiseHandControl.xaml.cs index 2f8d4aa0..f5e6e1e2 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/RaiseHandControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/RaiseHandControl.xaml.cs @@ -55,7 +55,22 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter RaisedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Hand_Raised.xaml") }; Icon.Content = IconResourceLoader.Load(LoweredIcon); - NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + NotificationButton.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); NotificationButton.PreviewMouseLeftButtonUp += NotificationButton_PreviewMouseLeftButtonUp; NotificationButton.PreviewMouseRightButtonUp += NotificationButton_PreviewMouseRightButtonUp; NotificationButton.ToolTip = text.Get(TextKey.Notification_ProctoringHandLowered); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs index 8ca165dd..2341508d 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs @@ -48,7 +48,22 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar audio.VolumeChanged += Audio_VolumeChanged; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); MuteButton.Click += MuteButton_Click; MutedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Audio_Muted.xaml") }; NoDeviceIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Audio_NoDevice.xaml") }; diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs index 145d5d0e..f8c1ea00 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs @@ -54,7 +54,22 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar ((LayoutsStackPanel.Children[0] as ContentControl).Content as UIElement).Focus(); }))); }; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs index a38ce91c..0cbbce48 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs @@ -45,8 +45,23 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar var originalBrush = Button.Background; adapter.Changed += () => Dispatcher.InvokeAsync(Update); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); WirelessIcon.Child = GetWirelessIcon(0); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/RaiseHandControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/RaiseHandControl.xaml.cs index 774cca6e..6db47fcd 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/RaiseHandControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/RaiseHandControl.xaml.cs @@ -55,7 +55,22 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar RaisedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Hand_Raised.xaml") }; Icon.Content = IconResourceLoader.Load(LoweredIcon); - NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + NotificationButton.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); NotificationButton.PreviewMouseLeftButtonUp += NotificationButton_PreviewMouseLeftButtonUp; NotificationButton.PreviewMouseRightButtonUp += NotificationButton_PreviewMouseRightButtonUp; NotificationButton.ToolTip = text.Get(TextKey.Notification_ProctoringHandLowered); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs index 13806e13..14f33945 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs @@ -49,7 +49,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter audio.VolumeChanged += Audio_VolumeChanged; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); MuteButton.Click += MuteButton_Click; MutedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/Audio_Muted.xaml") }; NoDeviceIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/Audio_Light_NoDevice.xaml") }; diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs index deb405b7..c2244737 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; using System.Threading.Tasks; using System.Windows.Automation; using System.Windows.Controls; @@ -50,7 +51,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter LayoutsStackPanel.Children[0].Focus(); })); }; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; Popup.Closed += (o, args) => Grid.Background = originalBrush; diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs index 15b4004f..5d1881fd 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs @@ -45,7 +45,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter adapter.Changed += () => Dispatcher.InvokeAsync(Update); Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; Popup.Closed += (o, args) => Grid.Background = originalBrush; diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/RaiseHandControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/RaiseHandControl.xaml.cs index f7f22918..e7479b8d 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/RaiseHandControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/RaiseHandControl.xaml.cs @@ -55,7 +55,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter RaisedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Hand_Raised.xaml") }; Icon.Content = IconResourceLoader.Load(LoweredIcon); - NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + NotificationButton.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); NotificationButton.PreviewMouseLeftButtonUp += NotificationButton_PreviewMouseLeftButtonUp; NotificationButton.PreviewMouseRightButtonUp += NotificationButton_PreviewMouseRightButtonUp; NotificationButton.ToolTip = text.Get(TextKey.Notification_ProctoringHandLowered); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs index 56aa2475..4ecc1938 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs @@ -48,7 +48,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar audio.VolumeChanged += Audio_VolumeChanged; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); MuteButton.Click += MuteButton_Click; MutedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/Audio_Muted.xaml") }; NoDeviceIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/Audio_NoDevice.xaml") }; diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs index dc5250d1..e126ac50 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs @@ -54,7 +54,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar ((LayoutsStackPanel.Children[0] as ContentControl).Content as UIElement).Focus(); }))); }; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs index b6bf3067..cdb47c27 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs @@ -46,7 +46,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar adapter.Changed += () => Dispatcher.InvokeAsync(Update); Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); WirelessIcon.Child = GetWirelessIcon(0); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/RaiseHandControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/RaiseHandControl.xaml.cs index 0c3c0690..79d2ae84 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/RaiseHandControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/RaiseHandControl.xaml.cs @@ -55,7 +55,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar RaisedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Hand_Raised.xaml") }; Icon.Content = IconResourceLoader.Load(LoweredIcon); - NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = DateTime.MinValue; + NotificationButton.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = DateTime.Now; + } + }; + NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); NotificationButton.PreviewMouseLeftButtonUp += NotificationButton_PreviewMouseLeftButtonUp; NotificationButton.PreviewMouseRightButtonUp += NotificationButton_PreviewMouseRightButtonUp; NotificationButton.ToolTip = text.Get(TextKey.Notification_ProctoringHandLowered); From 1ad20567b8084f5cd94b71bf9b757dc6cba7daec Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Mon, 13 Feb 2023 14:19:23 +0100 Subject: [PATCH 08/12] fix AudioControl nested focusability --- .../Controls/ActionCenter/AudioControl.xaml | 2 +- .../Controls/Taskbar/AudioControl.xaml | 2 +- .../Controls/ActionCenter/AudioControl.xaml | 2 +- .../Controls/Taskbar/AudioControl.xaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml index d81f0bf8..9a9c49a9 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml @@ -21,7 +21,7 @@ diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml index 229251fc..601e5f1c 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml @@ -22,7 +22,7 @@ diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml index b6c38225..948348d4 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml @@ -21,7 +21,7 @@ diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml index a17d3fe5..4fd4f2a2 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml @@ -22,7 +22,7 @@ From 5c5a70ad7392430c6704e143ebda0fa2455d659d Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Mon, 13 Feb 2023 18:11:05 +0100 Subject: [PATCH 09/12] fix WLAN menu keyboard accessibility --- .../Controls/ActionCenter/NetworkButton.xaml.cs | 5 +++++ .../Controls/ActionCenter/NetworkControl.xaml.cs | 13 ++++++++++++- .../Controls/Taskbar/NetworkButton.xaml.cs | 5 +++++ .../Controls/Taskbar/NetworkControl.xaml.cs | 8 ++++++++ .../Controls/ActionCenter/NetworkButton.xaml.cs | 5 +++++ .../Controls/ActionCenter/NetworkControl.xaml.cs | 13 ++++++++++++- .../Controls/Taskbar/NetworkButton.xaml.cs | 5 +++++ .../Controls/Taskbar/NetworkControl.xaml.cs | 8 ++++++++ 8 files changed, 60 insertions(+), 2 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkButton.xaml.cs index 8e940f07..ac1dc27a 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkButton.xaml.cs @@ -34,5 +34,10 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter NetworkNameTextBlock.Text = network.Name; SignalStrengthTextBlock.Text = $"{network.SignalStrength}%"; } + + public void SetFocus() + { + Button.Focus(); + } } } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs index d50efecd..47edeb73 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs @@ -62,7 +62,18 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter Popup.IsOpen = Popup.IsMouseOver; })); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); - Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; + Popup.Opened += (o, args) => + { + Grid.Background = Brushes.Gray; + Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => + { + var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; + if (btn != null) + { + btn.SetFocus(); + } + })); + }; Popup.Closed += (o, args) => Grid.Background = originalBrush; WirelessIcon.Child = GetWirelessIcon(0); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkButton.xaml.cs index cc3ec142..bc1d7025 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkButton.xaml.cs @@ -34,5 +34,10 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar NetworkNameTextBlock.Text = network.Name; SignalStrengthTextBlock.Text = $"{network.SignalStrength}%"; } + + public void SetFocus() + { + Button.Focus(); + } } } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs index 0cbbce48..b5f20e52 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs @@ -70,6 +70,14 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar { Background = Brushes.LightGray; Button.Background = Brushes.LightGray; + Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => + { + var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; + if (btn != null) + { + btn.SetFocus(); + } + })); }; Popup.Closed += (o, args) => diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkButton.xaml.cs index f464dccf..f8456e50 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkButton.xaml.cs @@ -34,5 +34,10 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter NetworkNameTextBlock.Text = network.Name; SignalStrengthTextBlock.Text = $"{network.SignalStrength}%"; } + + public void SetFocus() + { + Button.Focus(); + } } } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs index 5d1881fd..85da000e 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs @@ -62,7 +62,18 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter Popup.IsOpen = Popup.IsMouseOver; })); Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); - Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; + Popup.Opened += (o, args) => + { + Grid.Background = Brushes.Gray; + Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => + { + var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; + if (btn != null) + { + btn.SetFocus(); + } + })); + }; Popup.Closed += (o, args) => Grid.Background = originalBrush; WirelessIcon.Child = GetWirelessIcon(0); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkButton.xaml.cs index 76328c51..39f456e6 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkButton.xaml.cs @@ -34,5 +34,10 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar NetworkNameTextBlock.Text = network.Name; SignalStrengthTextBlock.Text = $"{network.SignalStrength}%"; } + + public void SetFocus() + { + Button.Focus(); + } } } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs index cdb47c27..284b67db 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs @@ -70,6 +70,14 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar { Background = Brushes.LightGray; Button.Background = Brushes.LightGray; + Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => + { + var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; + if (btn != null) + { + btn.SetFocus(); + } + })); }; Popup.Closed += (o, args) => From 094ff4765b236bd44062fda66b9703b85ef76dd4 Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Mon, 27 Feb 2023 13:25:23 +0100 Subject: [PATCH 10/12] fix modal auto-close --- .../ActionCenter/AudioControl.xaml.cs | 32 +++++++++++++++++-- .../KeyboardLayoutControl.xaml.cs | 21 +++++++++--- .../ActionCenter/NetworkControl.xaml.cs | 21 +++++++++--- .../ActionCenter/RaiseHandControl.xaml.cs | 21 +++++++++--- .../Controls/Taskbar/AudioControl.xaml.cs | 16 +++++++--- .../Taskbar/KeyboardLayoutControl.xaml.cs | 16 +++++++--- .../Controls/Taskbar/NetworkControl.xaml.cs | 16 +++++++--- .../Controls/Taskbar/RaiseHandControl.xaml.cs | 16 +++++++--- .../ActionCenter/AudioControl.xaml.cs | 21 +++++++++--- .../KeyboardLayoutControl.xaml.cs | 21 +++++++++--- .../ActionCenter/NetworkControl.xaml.cs | 21 +++++++++--- .../ActionCenter/RaiseHandControl.xaml.cs | 21 +++++++++--- .../Controls/Taskbar/AudioControl.xaml.cs | 16 +++++++--- .../Taskbar/KeyboardLayoutControl.xaml.cs | 16 +++++++--- .../Controls/Taskbar/NetworkControl.xaml.cs | 16 +++++++--- .../Controls/Taskbar/RaiseHandControl.xaml.cs | 16 +++++++--- 16 files changed, 237 insertions(+), 70 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs index 293491fb..42eb024d 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/AudioControl.xaml.cs @@ -49,13 +49,39 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter audio.VolumeChanged += Audio_VolumeChanged; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = Popup.IsMouseOver)); + var lastOpenedBySpacePress = false; + Button.PreviewKeyDown += (o, args) => + { + if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds + { + lastOpenedBySpacePress = true; + } + }; + Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = Popup.IsMouseOver; + })); MuteButton.Click += MuteButton_Click; MutedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Audio_Muted.xaml") }; NoDeviceIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Audio_Light_NoDevice.xaml") }; - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; - Popup.Closed += (o, args) => Grid.Background = originalBrush; + Popup.Closed += (o, args) => + { + Grid.Background = originalBrush; + lastOpenedBySpacePress = false; + }; Volume.ValueChanged += Volume_ValueChanged; if (audio.HasOutputDevice) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs index e43d7b5b..d9a5a85a 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs @@ -51,25 +51,36 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter LayoutsStackPanel.Children[0].Focus(); })); }; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } Popup.IsOpen = Popup.IsMouseOver; })); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; - Popup.Closed += (o, args) => Grid.Background = originalBrush; + Popup.Closed += (o, args) => + { + Grid.Background = originalBrush; + lastOpenedBySpacePress = false; + }; } private void Keyboard_LayoutChanged(IKeyboardLayout layout) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs index 47edeb73..099b0239 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs @@ -45,23 +45,30 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter adapter.Changed += () => Dispatcher.InvokeAsync(Update); Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } Popup.IsOpen = Popup.IsMouseOver; })); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => { Grid.Background = Brushes.Gray; @@ -74,7 +81,11 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter } })); }; - Popup.Closed += (o, args) => Grid.Background = originalBrush; + Popup.Closed += (o, args) => + { + Grid.Background = originalBrush; + lastOpenedBySpacePress = false; + }; WirelessIcon.Child = GetWirelessIcon(0); Update(); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/RaiseHandControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/RaiseHandControl.xaml.cs index f5e6e1e2..5ed86791 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/RaiseHandControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/RaiseHandControl.xaml.cs @@ -55,17 +55,17 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter RaisedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Hand_Raised.xaml") }; Icon.Content = IconResourceLoader.Load(LoweredIcon); - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; NotificationButton.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } @@ -76,9 +76,20 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter NotificationButton.ToolTip = text.Get(TextKey.Notification_ProctoringHandLowered); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; - Popup.Closed += (o, args) => Grid.Background = originalBrush; + Popup.Closed += (o, args) => + { + Grid.Background = originalBrush; + lastOpenedBySpacePress = false; + }; Text.Text = text.Get(TextKey.Notification_ProctoringHandLowered); } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs index 2341508d..2eafc925 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/AudioControl.xaml.cs @@ -48,17 +48,17 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar audio.VolumeChanged += Audio_VolumeChanged; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } @@ -68,7 +68,14 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar MutedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Audio_Muted.xaml") }; NoDeviceIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Audio_NoDevice.xaml") }; Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Volume.ValueChanged += Volume_ValueChanged; Popup.Opened += (o, args) => @@ -82,6 +89,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar { Background = originalBrush; Button.Background = originalBrush; + lastOpenedBySpacePress = false; }; if (audio.HasOutputDevice) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs index f8c1ea00..3f4cf0dc 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutControl.xaml.cs @@ -54,24 +54,31 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar ((LayoutsStackPanel.Children[0] as ContentControl).Content as UIElement).Focus(); }))); }; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } Popup.IsOpen = Popup.IsMouseOver; })); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => { @@ -83,6 +90,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar { Background = originalBrush; Button.Background = originalBrush; + lastOpenedBySpacePress = false; }; } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs index b5f20e52..4cc6793b 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs @@ -45,25 +45,32 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar var originalBrush = Button.Background; adapter.Changed += () => Dispatcher.InvokeAsync(Update); - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } Popup.IsOpen = Popup.IsMouseOver; })); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); WirelessIcon.Child = GetWirelessIcon(0); Popup.Opened += (o, args) => @@ -84,6 +91,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar { Background = originalBrush; Button.Background = originalBrush; + lastOpenedBySpacePress = false; }; Update(); diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/RaiseHandControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/RaiseHandControl.xaml.cs index 6db47fcd..01aeb2ac 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/RaiseHandControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/RaiseHandControl.xaml.cs @@ -55,17 +55,17 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar RaisedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Hand_Raised.xaml") }; Icon.Content = IconResourceLoader.Load(LoweredIcon); - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; NotificationButton.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } @@ -76,7 +76,14 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar NotificationButton.ToolTip = text.Get(TextKey.Notification_ProctoringHandLowered); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => { Background = Brushes.LightGray; @@ -86,6 +93,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar { Background = originalBrush; NotificationButton.Background = originalBrush; + lastOpenedBySpacePress = false; }; } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs index 14f33945..5df57574 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/AudioControl.xaml.cs @@ -49,17 +49,17 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter audio.VolumeChanged += Audio_VolumeChanged; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } @@ -68,9 +68,20 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter MuteButton.Click += MuteButton_Click; MutedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/Audio_Muted.xaml") }; NoDeviceIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/Audio_Light_NoDevice.xaml") }; - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; - Popup.Closed += (o, args) => Grid.Background = originalBrush; + Popup.Closed += (o, args) => + { + Grid.Background = originalBrush; + lastOpenedBySpacePress = false; + }; Volume.ValueChanged += Volume_ValueChanged; if (audio.HasOutputDevice) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs index c2244737..43912d1d 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutControl.xaml.cs @@ -51,25 +51,36 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter LayoutsStackPanel.Children[0].Focus(); })); }; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } Popup.IsOpen = Popup.IsMouseOver; })); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; - Popup.Closed += (o, args) => Grid.Background = originalBrush; + Popup.Closed += (o, args) => + { + Grid.Background = originalBrush; + lastOpenedBySpacePress = false; + }; } private void Keyboard_LayoutChanged(IKeyboardLayout layout) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs index 85da000e..349418b4 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs @@ -45,23 +45,30 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter adapter.Changed += () => Dispatcher.InvokeAsync(Update); Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } Popup.IsOpen = Popup.IsMouseOver; })); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => { Grid.Background = Brushes.Gray; @@ -74,7 +81,11 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter } })); }; - Popup.Closed += (o, args) => Grid.Background = originalBrush; + Popup.Closed += (o, args) => + { + Grid.Background = originalBrush; + lastOpenedBySpacePress = false; + }; WirelessIcon.Child = GetWirelessIcon(0); Update(); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/RaiseHandControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/RaiseHandControl.xaml.cs index e7479b8d..b07add7f 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/RaiseHandControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/RaiseHandControl.xaml.cs @@ -55,17 +55,17 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter RaisedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Hand_Raised.xaml") }; Icon.Content = IconResourceLoader.Load(LoweredIcon); - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; NotificationButton.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } @@ -76,9 +76,20 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter NotificationButton.ToolTip = text.Get(TextKey.Notification_ProctoringHandLowered); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => Grid.Background = Brushes.Gray; - Popup.Closed += (o, args) => Grid.Background = originalBrush; + Popup.Closed += (o, args) => + { + Grid.Background = originalBrush; + lastOpenedBySpacePress = false; + }; Text.Text = text.Get(TextKey.Notification_ProctoringHandLowered); } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs index 4ecc1938..ec1b72a8 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/AudioControl.xaml.cs @@ -48,17 +48,17 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar audio.VolumeChanged += Audio_VolumeChanged; Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } @@ -68,7 +68,14 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar MutedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/Audio_Muted.xaml") }; NoDeviceIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/Audio_NoDevice.xaml") }; Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Volume.ValueChanged += Volume_ValueChanged; Popup.Opened += (o, args) => @@ -82,6 +89,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar { Background = originalBrush; Button.Background = originalBrush; + lastOpenedBySpacePress = false; }; if (audio.HasOutputDevice) diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs index e126ac50..5195ccf1 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutControl.xaml.cs @@ -54,24 +54,31 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar ((LayoutsStackPanel.Children[0] as ContentControl).Content as UIElement).Focus(); }))); }; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } Popup.IsOpen = Popup.IsMouseOver; })); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => { @@ -83,6 +90,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar { Background = originalBrush; Button.Background = originalBrush; + lastOpenedBySpacePress = false; }; } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs index 284b67db..7b21a7e3 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs @@ -46,24 +46,31 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar adapter.Changed += () => Dispatcher.InvokeAsync(Update); Button.Click += (o, args) => Popup.IsOpen = !Popup.IsOpen; - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; Button.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } Popup.IsOpen = Popup.IsMouseOver; })); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); WirelessIcon.Child = GetWirelessIcon(0); Popup.Opened += (o, args) => @@ -84,6 +91,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar { Background = originalBrush; Button.Background = originalBrush; + lastOpenedBySpacePress = false; }; Update(); diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/RaiseHandControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/RaiseHandControl.xaml.cs index 79d2ae84..68772cb3 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/RaiseHandControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/RaiseHandControl.xaml.cs @@ -55,17 +55,17 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar RaisedIcon = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Hand_Raised.xaml") }; Icon.Content = IconResourceLoader.Load(LoweredIcon); - var lastOpenedBySpacePress = DateTime.MinValue; + var lastOpenedBySpacePress = false; NotificationButton.PreviewKeyDown += (o, args) => { if (args.Key == System.Windows.Input.Key.Space) // for some reason, the popup immediately closes again if opened by a Space Bar key event - as a mitigation, we record the space bar event and leave the popup open for at least 3 seconds { - lastOpenedBySpacePress = DateTime.Now; + lastOpenedBySpacePress = true; } }; NotificationButton.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => { - if (Popup.IsOpen && (DateTime.Now - lastOpenedBySpacePress).TotalSeconds < 3) + if (Popup.IsOpen && lastOpenedBySpacePress) { return; } @@ -76,7 +76,14 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar NotificationButton.ToolTip = text.Get(TextKey.Notification_ProctoringHandLowered); Popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(Popup_PlacementCallback); - Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver)); + Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => + { + if (Popup.IsOpen && lastOpenedBySpacePress) + { + return; + } + Popup.IsOpen = IsMouseOver; + })); Popup.Opened += (o, args) => { Background = Brushes.LightGray; @@ -87,6 +94,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar { Background = originalBrush; NotificationButton.Background = originalBrush; + lastOpenedBySpacePress = false; }; } From 3ca514e653adf1f0c351ea18f0ae5ab6cdbfdb4a Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Mon, 27 Feb 2023 17:32:11 +0100 Subject: [PATCH 11/12] accessibility bugfixes --- .../Controls/ActionCenter/KeyboardLayoutButton.xaml.cs | 1 + .../Controls/Taskbar/KeyboardLayoutButton.xaml.cs | 2 +- .../Controls/Taskbar/NotificationButton.xaml.cs | 1 + .../Controls/ActionCenter/KeyboardLayoutButton.xaml.cs | 1 + .../Controls/Taskbar/KeyboardLayoutButton.xaml.cs | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutButton.xaml.cs index 44a6f756..5e5607f8 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/KeyboardLayoutButton.xaml.cs @@ -43,6 +43,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter CultureCodeTextBlock.Text = layout.CultureCode; CultureNameTextBlock.Text = layout.CultureName; LayoutNameTextBlock.Text = layout.LayoutName; + System.Windows.Automation.AutomationProperties.SetName(Button, layout.CultureName); } } } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutButton.xaml.cs index 18107a60..ea993856 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/KeyboardLayoutButton.xaml.cs @@ -43,7 +43,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar CultureCodeTextBlock.Text = layout.CultureCode; CultureNameTextBlock.Text = layout.CultureName; LayoutNameTextBlock.Text = layout.LayoutName; - System.Windows.Automation.AutomationProperties.SetName(Button, layout.LayoutName); + System.Windows.Automation.AutomationProperties.SetName(Button, layout.CultureName); } } } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NotificationButton.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NotificationButton.xaml.cs index 6c1a7f3f..b415cbf0 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NotificationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NotificationButton.xaml.cs @@ -41,6 +41,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar { IconButton.ToolTip = notification.Tooltip; IconButton.Content = IconResourceLoader.Load(notification.IconResource); + System.Windows.Automation.AutomationProperties.SetName(this, notification.Tooltip); } } } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutButton.xaml.cs index 7813146a..1b14edb7 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/KeyboardLayoutButton.xaml.cs @@ -43,6 +43,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter CultureCodeTextBlock.Text = layout.CultureCode; CultureNameTextBlock.Text = layout.CultureName; LayoutNameTextBlock.Text = layout.LayoutName; + System.Windows.Automation.AutomationProperties.SetName(Button, layout.CultureName); } } } diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutButton.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutButton.xaml.cs index e71ef817..a1d2812b 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutButton.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/KeyboardLayoutButton.xaml.cs @@ -43,7 +43,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar CultureCodeTextBlock.Text = layout.CultureCode; CultureNameTextBlock.Text = layout.CultureName; LayoutNameTextBlock.Text = layout.LayoutName; - System.Windows.Automation.AutomationProperties.SetName(Button, layout.LayoutName); + System.Windows.Automation.AutomationProperties.SetName(Button, layout.CultureName); } } } From 298e8f34f420fece3f5908ce9d8034ec4875e4d2 Mon Sep 17 00:00:00 2001 From: Jonas Sourlier Date: Mon, 6 Mar 2023 17:03:01 +0100 Subject: [PATCH 12/12] fix possible IndexOutOfRangeException --- .../Controls/ActionCenter/NetworkControl.xaml.cs | 9 ++++++--- .../Controls/Taskbar/NetworkControl.xaml.cs | 9 ++++++--- .../Controls/ActionCenter/NetworkControl.xaml.cs | 9 ++++++--- .../Controls/Taskbar/NetworkControl.xaml.cs | 9 ++++++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs index 099b0239..0cb17a58 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NetworkControl.xaml.cs @@ -74,10 +74,13 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter Grid.Background = Brushes.Gray; Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => { - var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; - if (btn != null) + if (WirelessNetworksStackPanel.Children.Count > 0) { - btn.SetFocus(); + var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; + if (btn != null) + { + btn.SetFocus(); + } } })); }; diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs index 4cc6793b..b9bf15d9 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/Taskbar/NetworkControl.xaml.cs @@ -79,10 +79,13 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar Button.Background = Brushes.LightGray; Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => { - var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; - if (btn != null) + if (WirelessNetworksStackPanel.Children.Count > 0) { - btn.SetFocus(); + var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; + if (btn != null) + { + btn.SetFocus(); + } } })); }; diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs index 349418b4..9231578b 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/ActionCenter/NetworkControl.xaml.cs @@ -74,10 +74,13 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter Grid.Background = Brushes.Gray; Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => { - var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; - if (btn != null) + if (WirelessNetworksStackPanel.Children.Count > 0) { - btn.SetFocus(); + var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; + if (btn != null) + { + btn.SetFocus(); + } } })); }; diff --git a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs index 7b21a7e3..89360a6a 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Controls/Taskbar/NetworkControl.xaml.cs @@ -79,10 +79,13 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar Button.Background = Brushes.LightGray; Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => { - var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; - if (btn != null) + if (WirelessNetworksStackPanel.Children.Count > 0) { - btn.SetFocus(); + var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; + if (btn != null) + { + btn.SetFocus(); + } } })); };