SupaLidlGame/Debug/Entry.cs

49 lines
1017 B
C#
Raw Normal View History

2023-09-24 18:51:23 -07:00
using Godot;
namespace SupaLidlGame.Debug;
public partial class Entry : CodeEdit
2023-09-24 18:51:23 -07:00
{
[Signal]
public delegate void ConsoleInputEventHandler(string input);
public override void _Ready()
{
GuiInput += OnGuiInput;
}
/*
public override void _Input(InputEvent @event)
{
if (HasFocus())
{
if (@event is InputEventKey && @event.IsPressed())
{
AcceptEvent();
OnGuiInput(@event);
}
}
}
*/
2023-09-24 18:51:23 -07:00
public void OnGuiInput(InputEvent @event)
{
if (@event is InputEventKey key)
{
if (key.KeyLabel == Key.Enter)
2023-09-24 18:51:23 -07:00
{
AcceptEvent();
if (!key.Pressed)
2023-09-24 18:51:23 -07:00
{
EmitSignal(SignalName.ConsoleInput, Text);
if (!key.IsCommandOrControlPressed())
{
Text = "";
}
2023-09-24 18:51:23 -07:00
}
}
}
}
}