feat: move dot to text input handling. fix numpad return key in num mode.

This commit is contained in:
rabbitism
2024-03-16 17:07:34 +08:00
parent fc69b4275d
commit 52ba6459c4
2 changed files with 28 additions and 32 deletions

View File

@@ -136,7 +136,7 @@ public class IPv4Box: TemplatedControl
if (_currentActivePresenter is null) return;
var keymap = TopLevel.GetTopLevel(this)?.PlatformSettings?.HotkeyConfiguration;
bool Match(List<KeyGesture> gestures) => gestures.Any(g => g.Matches(e));
if (e.Key == Key.Enter)
if (e.Key is Key.Enter or Key.Return)
{
ParseBytes(ShowLeadingZero);
SetIPAddressInternal();
@@ -170,25 +170,6 @@ public class IPv4Box: TemplatedControl
_currentActivePresenter?.ShowCaret();
e.Handled = true;
}
else if (e.Key == Key.OemPeriod || e.Key == Key.Decimal)
{
if (string.IsNullOrEmpty(_currentActivePresenter.Text))
{
base.OnKeyDown(e);
return;
}
_currentActivePresenter?.HideCaret();
_currentActivePresenter.ClearSelection();
if (Equals(_currentActivePresenter, _fourthText))
{
base.OnKeyDown(e);
return;
}
MoveToNextPresenter(_currentActivePresenter, false);
_currentActivePresenter?.ShowCaret();
_currentActivePresenter.MoveCaretToStart();
e.Handled = true;
}
else if (e.Key == Key.Back)
{
DeleteImplementation(_currentActivePresenter);
@@ -212,6 +193,16 @@ public class IPv4Box: TemplatedControl
if (e.Handled) return;
string? s = e.Text;
if (string.IsNullOrEmpty(s)) return;
if (s == ".")
{
_currentActivePresenter?.HideCaret();
_currentActivePresenter.ClearSelection();
MoveToNextPresenter(_currentActivePresenter, false);
_currentActivePresenter?.ShowCaret();
_currentActivePresenter.MoveCaretToStart();
e.Handled = false;
return;
}
if (!char.IsNumber(s![0])) return;
if (_currentActivePresenter != null)
{