feat: simplify code with switch.
This commit is contained in:
@@ -190,27 +190,23 @@ public class DatePicker: DatePickerBase, IClearControl
|
|||||||
|
|
||||||
protected override void OnKeyDown(KeyEventArgs e)
|
protected override void OnKeyDown(KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Escape)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
SetCurrentValue(IsDropdownOpenProperty, false);
|
case Key.Escape:
|
||||||
e.Handled = true;
|
SetCurrentValue(IsDropdownOpenProperty, false);
|
||||||
return;
|
e.Handled = true;
|
||||||
|
return;
|
||||||
|
case Key.Down:
|
||||||
|
SetCurrentValue(IsDropdownOpenProperty, true);
|
||||||
|
e.Handled = true;
|
||||||
|
return;
|
||||||
|
case Key.Tab:
|
||||||
|
SetCurrentValue(IsDropdownOpenProperty, false);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
base.OnKeyDown(e);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.Key == Key.Down)
|
|
||||||
{
|
|
||||||
SetCurrentValue(IsDropdownOpenProperty, true);
|
|
||||||
e.Handled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.Key == Key.Tab)
|
|
||||||
{
|
|
||||||
SetCurrentValue(IsDropdownOpenProperty, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnKeyDown(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
|
|||||||
@@ -434,30 +434,28 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
|||||||
|
|
||||||
protected override void OnKeyDown(KeyEventArgs e)
|
protected override void OnKeyDown(KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Escape)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
SetCurrentValue(IsDropdownOpenProperty, false);
|
case Key.Escape:
|
||||||
e.Handled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.Key == Key.Down)
|
|
||||||
{
|
|
||||||
SetCurrentValue(IsDropdownOpenProperty, true);
|
|
||||||
e.Handled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.Key == Key.Tab)
|
|
||||||
{
|
|
||||||
if(_endTextBox?.IsFocused == true)
|
|
||||||
{
|
|
||||||
SetCurrentValue(IsDropdownOpenProperty, false);
|
SetCurrentValue(IsDropdownOpenProperty, false);
|
||||||
|
e.Handled = true;
|
||||||
|
return;
|
||||||
|
case Key.Down:
|
||||||
|
SetCurrentValue(IsDropdownOpenProperty, true);
|
||||||
|
e.Handled = true;
|
||||||
|
return;
|
||||||
|
case Key.Tab:
|
||||||
|
{
|
||||||
|
if(_endTextBox?.IsFocused == true)
|
||||||
|
{
|
||||||
|
SetCurrentValue(IsDropdownOpenProperty, false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
default:
|
||||||
|
base.OnKeyDown(e);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnKeyDown(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user