fix: fix tab navigation behavior.

This commit is contained in:
rabbitism
2024-04-27 11:36:04 +08:00
parent 31847513d9
commit 706147a6a7

View File

@@ -63,10 +63,8 @@ public class TimePicker : TemplatedControl, IClearControl, IInnerContentControl,
nameof(IsReadonly));
private Button? _button;
private Popup? _popup;
private TimePickerPresenter? _presenter;
private TextBox? _textBox;
@@ -185,6 +183,29 @@ public class TimePicker : TemplatedControl, IClearControl, IInnerContentControl,
IsDropdownOpen = true;
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
SetCurrentValue(IsDropdownOpenProperty, false);
e.Handled = true;
return;
}
if (e.Key == Key.Down)
{
SetCurrentValue(IsDropdownOpenProperty, true);
e.Handled = true;
return;
}
if (e.Key == Key.Tab)
{
SetCurrentValue(IsDropdownOpenProperty, false);
return;
}
base.OnKeyDown(e);
}
private void OnTextChanged(object? sender, TextChangedEventArgs e)
{