i hope this works for you (i added a fps counter to see when it crashes)
it has to do with changing the text within events.
the events are not running in seperate threads arent they?
using System;
namespace SFMLTest
{
public class Blub
{
SFML.Graphics.RenderWindow window;
SFML.Graphics.String2D stringObject;
SFML.Graphics.String2D fps;
//string content = "";
public void Run()
{
window = new SFML.Graphics.RenderWindow(new SFML.Window.VideoMode(800, 600), "test");
window.Closed += new EventHandler(OnClose);
window.TextEntered += new EventHandler<SFML.Window.TextEventArgs>(OnTextEntered);
window.SetFramerateLimit(60);
stringObject = new SFML.Graphics.String2D("text");
stringObject.Position = new SFML.Graphics.Vector2(10, 100);
fps = new SFML.Graphics.String2D("0");
fps.Position = new SFML.Graphics.Vector2(500, 10);
while (window.IsOpened())
{
float deltaTime = window.GetFrameTime();
window.DispatchEvents();
Update();
window.Clear();
Draw();
window.Display();
}
}
private void Update()
{
fps.Text = "" + (1f / window.GetFrameTime());
//stringObject.Text = content;
}
private void Draw()
{
window.Draw(stringObject);
window.Draw(fps);
}
private void OnTextEntered(object sender, SFML.Window.TextEventArgs args)
{
if (args.Unicode.ToCharArray()[0] > 31)
{
//content += args.Unicode;
stringObject.Text += args.Unicode;
}
}
private void OnClose(object sender, EventArgs e)
{
window.Close();
}
}
}
it breaks in OnTextEntered when typing very fast.
when im using a seperate string to modify and then assign it in update to the string2d (commented out), it works just fine.