Free Text Input
using System;
using odl;
namespace TestNamespace
{
class Program
{
static void Main(string[] args)
{
Graphics.Start();
Window win = new Window();
win.Initialize(true, true);
Viewport vp = new Viewport(0, 0, win.Width, win.Height);
Sprite s = new Sprite(vp);
s.Bitmap = new Bitmap(vp.Width, vp.Height);
s.Bitmap.Font = Font.Get("arial", 24);
string text = "";
win.Show();
win.OnTextInput += delegate (TextEventArgs e)
{
string oldtext = text;
if (e.Backspace)
{
if (text.Length > 0) text = text.Remove(text.Length - 1);
}
else if (e.Delete) { }
else
{
text += e.Text;
}
if (text != oldtext)
{
s.Bitmap.Unlock();
s.Bitmap.Clear();
s.Bitmap.DrawText(text, 5, 20, Color.WHITE);
s.Bitmap.Lock();
}
};
Input.StartTextInput();
while (Graphics.CanUpdate())
{
Graphics.Update();
}
Input.StopTextInput();
if (!vp.Disposed) vp.Dispose();
Graphics.Stop();
}
}
}
Last updated