SEBWIN-668, #589: Fixed crash when using SEB without browser and pressing the Windows key.
This commit is contained in:
parent
65840f646e
commit
dab86a31f5
2 changed files with 18 additions and 28 deletions
|
@ -198,7 +198,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows
|
||||||
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||||
{
|
{
|
||||||
isQuitButtonFocusedAtKeyDown = QuitButton.IsKeyboardFocusWithin;
|
isQuitButtonFocusedAtKeyDown = QuitButton.IsKeyboardFocusWithin;
|
||||||
isFirstChildFocusedAtKeyDown = ApplicationStackPanel.Children[0].IsKeyboardFocusWithin;
|
isFirstChildFocusedAtKeyDown = ApplicationStackPanel.Children.Count > 0 && ApplicationStackPanel.Children[0].IsKeyboardFocusWithin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
|
private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
|
||||||
|
@ -206,7 +206,9 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows
|
||||||
if (e.Key == System.Windows.Input.Key.Tab)
|
if (e.Key == System.Windows.Input.Key.Tab)
|
||||||
{
|
{
|
||||||
var shift = System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.LeftShift);
|
var shift = System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.LeftShift);
|
||||||
if (!shift && ApplicationStackPanel.Children[0].IsKeyboardFocusWithin && isQuitButtonFocusedAtKeyDown)
|
var hasFocus = ApplicationStackPanel.Children.Count > 0 && ApplicationStackPanel.Children[0].IsKeyboardFocusWithin;
|
||||||
|
|
||||||
|
if (!shift && hasFocus && isQuitButtonFocusedAtKeyDown)
|
||||||
{
|
{
|
||||||
LoseFocusRequested?.Invoke(true);
|
LoseFocusRequested?.Invoke(true);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
|
|
@ -196,8 +196,8 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows
|
||||||
|
|
||||||
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||||
{
|
{
|
||||||
this.isQuitButtonFocusedAtKeyDown = this.QuitButton.IsKeyboardFocusWithin;
|
isQuitButtonFocusedAtKeyDown = QuitButton.IsKeyboardFocusWithin;
|
||||||
this.isFirstChildFocusedAtKeyDown = this.ApplicationStackPanel.Children[0].IsKeyboardFocusWithin;
|
isFirstChildFocusedAtKeyDown = ApplicationStackPanel.Children.Count > 0 && ApplicationStackPanel.Children[0].IsKeyboardFocusWithin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
|
private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
|
||||||
|
@ -205,36 +205,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows
|
||||||
if (e.Key == System.Windows.Input.Key.Tab)
|
if (e.Key == System.Windows.Input.Key.Tab)
|
||||||
{
|
{
|
||||||
var shift = System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.LeftShift);
|
var shift = System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.LeftShift);
|
||||||
if (!shift && this.ApplicationStackPanel.Children[0].IsKeyboardFocusWithin && this.isQuitButtonFocusedAtKeyDown)
|
var hasFocus = ApplicationStackPanel.Children.Count > 0 && ApplicationStackPanel.Children[0].IsKeyboardFocusWithin;
|
||||||
|
|
||||||
|
if (!shift && hasFocus && isQuitButtonFocusedAtKeyDown)
|
||||||
{
|
{
|
||||||
this.LoseFocusRequested?.Invoke(true);
|
LoseFocusRequested?.Invoke(true);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
else if (shift && this.QuitButton.IsKeyboardFocusWithin && this.isFirstChildFocusedAtKeyDown)
|
else if (shift && QuitButton.IsKeyboardFocusWithin && isFirstChildFocusedAtKeyDown)
|
||||||
{
|
{
|
||||||
this.LoseFocusRequested?.Invoke(false);
|
LoseFocusRequested?.Invoke(false);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isQuitButtonFocusedAtKeyDown = false;
|
isQuitButtonFocusedAtKeyDown = false;
|
||||||
this.isFirstChildFocusedAtKeyDown = false;
|
isFirstChildFocusedAtKeyDown = false;
|
||||||
}
|
|
||||||
|
|
||||||
void ITaskbar.Focus(bool forward)
|
|
||||||
{
|
|
||||||
this.Dispatcher.BeginInvoke((Action) (() =>
|
|
||||||
{
|
|
||||||
base.Activate();
|
|
||||||
if (forward)
|
|
||||||
{
|
|
||||||
this.SetFocusWithin(this.ApplicationStackPanel.Children[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.QuitButton.Focus();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetFocusWithin(UIElement uIElement)
|
private bool SetFocusWithin(UIElement uIElement)
|
||||||
|
@ -248,9 +234,10 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows
|
||||||
if (uIElement is System.Windows.Controls.Panel)
|
if (uIElement is System.Windows.Controls.Panel)
|
||||||
{
|
{
|
||||||
var panel = uIElement as System.Windows.Controls.Panel;
|
var panel = uIElement as System.Windows.Controls.Panel;
|
||||||
|
|
||||||
for (var i = 0; i < panel.Children.Count; i++)
|
for (var i = 0; i < panel.Children.Count; i++)
|
||||||
{
|
{
|
||||||
if (this.SetFocusWithin(panel.Children[i]))
|
if (SetFocusWithin(panel.Children[i]))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -262,9 +249,10 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows
|
||||||
{
|
{
|
||||||
var control = uIElement as System.Windows.Controls.ContentControl;
|
var control = uIElement as System.Windows.Controls.ContentControl;
|
||||||
var content = control.Content as UIElement;
|
var content = control.Content as UIElement;
|
||||||
|
|
||||||
if (content != null)
|
if (content != null)
|
||||||
{
|
{
|
||||||
return this.SetFocusWithin(content);
|
return SetFocusWithin(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue