Fix ESC handling in ticket completion dropdowns

This commit is contained in:
Meik
2026-02-20 14:55:35 +01:00
parent dd0e7bdc99
commit 234eacaecf
4 changed files with 3489 additions and 3422 deletions

View File

@@ -1,7 +1,7 @@
using C4IT.FASD.Base;
using C4IT.MultiLanguage;
using FasdDesktopUi.Basics.Helper;
using FasdDesktopUi.Basics.Models;
using C4IT.MultiLanguage;
using FasdDesktopUi.Basics.Helper;
using FasdDesktopUi.Basics.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -125,25 +125,25 @@ namespace FasdDesktopUi.Basics.UserControls
}
public static readonly DependencyProperty SearchDataChangedProperty =
DependencyProperty.Register("SearchDataChanged", typeof(EventHandler<cF4sdHealthSelectionDataRequest>), typeof(ComboBoxPageable), new PropertyMetadata(null));
#endregion
#region RestoreParentScrollFocusOnDropDownClose
public bool RestoreParentScrollFocusOnDropDownClose
{
get { return (bool)GetValue(RestoreParentScrollFocusOnDropDownCloseProperty); }
set { SetValue(RestoreParentScrollFocusOnDropDownCloseProperty, value); }
}
public static readonly DependencyProperty RestoreParentScrollFocusOnDropDownCloseProperty =
DependencyProperty.Register("RestoreParentScrollFocusOnDropDownClose", typeof(bool), typeof(ComboBoxPageable), new PropertyMetadata(false));
#endregion
#region ItemData
public static readonly DependencyProperty SearchDataChangedProperty =
DependencyProperty.Register("SearchDataChanged", typeof(EventHandler<cF4sdHealthSelectionDataRequest>), typeof(ComboBoxPageable), new PropertyMetadata(null));
#endregion
#region RestoreParentScrollFocusOnDropDownClose
public bool RestoreParentScrollFocusOnDropDownClose
{
get { return (bool)GetValue(RestoreParentScrollFocusOnDropDownCloseProperty); }
set { SetValue(RestoreParentScrollFocusOnDropDownCloseProperty, value); }
}
public static readonly DependencyProperty RestoreParentScrollFocusOnDropDownCloseProperty =
DependencyProperty.Register("RestoreParentScrollFocusOnDropDownClose", typeof(bool), typeof(ComboBoxPageable), new PropertyMetadata(false));
#endregion
#region ItemData
public ObservableCollection<KeyValuePair<string, object>> ItemData
{
@@ -222,6 +222,15 @@ namespace FasdDesktopUi.Basics.UserControls
return null;
}
public bool CloseDropDownIfOpen()
{
if (ComboBoxControl?.IsDropDownOpen != true)
return false;
ComboBoxControl.IsDropDownOpen = false;
return true;
}
#region Paging Events
#region PageBack
@@ -316,33 +325,33 @@ namespace FasdDesktopUi.Basics.UserControls
}
}
private void ComboBoxControl_DropDownClosed(object sender, EventArgs e)
{
timer.Stop();
cFocusInvoker.InvokeLostFocus(this, e);
if (RestoreParentScrollFocusOnDropDownClose)
{
_ = Dispatcher.BeginInvoke((Action)(() =>
{
try
{
var parentScrollViewer = cUiElementHelper.GetFirstParentOfType<ScrollViewer>(this);
Keyboard.ClearFocus();
if (parentScrollViewer != null)
{
parentScrollViewer.Focus();
Keyboard.Focus(parentScrollViewer);
}
}
catch (Exception exception)
{
LogException(exception);
}
}), System.Windows.Threading.DispatcherPriority.Input);
}
}
private void ComboBoxControl_DropDownClosed(object sender, EventArgs e)
{
timer.Stop();
cFocusInvoker.InvokeLostFocus(this, e);
if (RestoreParentScrollFocusOnDropDownClose)
{
_ = Dispatcher.BeginInvoke((Action)(() =>
{
try
{
var parentScrollViewer = cUiElementHelper.GetFirstParentOfType<ScrollViewer>(this);
Keyboard.ClearFocus();
if (parentScrollViewer != null)
{
parentScrollViewer.Focus();
Keyboard.Focus(parentScrollViewer);
}
}
catch (Exception exception)
{
LogException(exception);
}
}), System.Windows.Threading.DispatcherPriority.Input);
}
}
private void ComboBoxControl_DropDownOpened(object sender, EventArgs e)
{