SofiaConsole icon indicating copy to clipboard operation
SofiaConsole copied to clipboard

CommandInput ignoring backspace and enter keys

Open gvvim opened this issue 1 year ago • 0 comments

(Godot v4.2.2)

Seems to be related to this issue with Godot engine. But the only way to fix it that I've found is to manually check for these events so I'm sharing the fix here, in case someone else runs into this issue.

Add this to _EnterTree in Console.cs:

_commandInput.GuiInput += (InputEvent @event) =>
{
	if (@event is InputEventKey key && key.Pressed)
	{
	        if (key.Keycode == Key.Backspace)
	        {
		        _commandInput.DeleteText(_commandInput.CaretColumn - 1, _commandInput.CaretColumn);
	        }
	        else if (key.Keycode == Key.Enter)
	        {
		        ProcessCommand(_commandInput.Text);
	        }
	}
};

gvvim avatar Nov 20 '24 12:11 gvvim