On another note, since the application is already coded using SFML, I designed it to update every frame. Since GTK takes over the main loop, the application would not be able to update every frame unless something like this is used (from the tutorial I mentioned).
/// <summary>
/// Timer handler. Since GTK controlls the main loop we need this to poll SFML events.
/// </summary>
private void OnTimerElapsed()
{
Gtk.Application.Invoke(
delegate
{
DispatchEvents();
Redraw();
Display();
});
}
But I do not understand why the author calls the update code from the OnTimerElapsed() method. Maybe it happens every frame?
I have also been looking into a GUI library called TGUI.Net. It might be better in this situation because:
- It doesn't take over the main thread.
- It's widgets embed into a SFML window.
- Event handling can still be done through SFML without calling an update function from OnTimerElasped().