fix modal auto-close

This commit is contained in:
Jonas Sourlier 2023-02-27 13:25:23 +01:00
parent 5c5a70ad73
commit 094ff4765b
16 changed files with 237 additions and 70 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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();

View file

@ -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);
}

View file

@ -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)

View file

@ -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;
};
}

View file

@ -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();

View file

@ -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;
};
}

View file

@ -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)

View file

@ -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)

View file

@ -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();

View file

@ -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);
}

View file

@ -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)

View file

@ -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;
};
}

View file

@ -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();

View file

@ -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;
};
}