This commit is contained in:
CortexCore
2025-01-12 11:13:19 +08:00
parent 01e7e4e35e
commit 01b3d1be43
26 changed files with 387 additions and 336 deletions

View File

@@ -228,9 +228,24 @@ namespace BITKit.Console
_commandSelector.SetMethods(null);
}
}
private async void OnKeyDown(KeyDownEvent keyDownEvent)
private bool _stopNextFrame;
private void OnKeyDown(KeyDownEvent keyDownEvent)
{
var nextStop=true;
if (_stopNextFrame)
{
keyDownEvent.StopPropagation();
keyDownEvent.PreventDefault();
_stopNextFrame = false;
}
if (keyDownEvent.keyCode is KeyCode.BackQuote)
{
keyDownEvent.StopPropagation();
keyDownEvent.PreventDefault();
_stopNextFrame = true;
return;
}
switch (keyDownEvent.keyCode)
{
case KeyCode.Return:
@@ -240,35 +255,30 @@ namespace BITKit.Console
_textField.SetValueWithoutNotify(string.Empty);
await UniTask.NextFrame();
_textField.Blur();
_textField.Focus();
BITCommands.Excute(cmd);
_commandSelector.SetMethods(null);
keyDownEvent.StopPropagation();
keyDownEvent.PreventDefault();
_stopNextFrame = true;
break;
case KeyCode.Tab:
keyDownEvent.StopPropagation();
keyDownEvent.PreventDefault();
break;
case KeyCode.DownArrow when string.IsNullOrEmpty(_textField.text) is false:
_commandSelector.Index-=1;
keyDownEvent.StopPropagation();
keyDownEvent.PreventDefault();
break;
case KeyCode.UpArrow when string.IsNullOrEmpty(_textField.text) is false:
_commandSelector.Index+=1;
break;
default:
nextStop = false;
keyDownEvent.StopPropagation();
keyDownEvent.PreventDefault();
break;
}
if (nextStop)
{
keyDownEvent.StopPropagation();
keyDownEvent.PreventDefault();
}
}
private async void LogCallback(string condition, string stackTrace, LogType type)
{