On 18-04-2019 12:46, wolfgang wrote:


I'm developing an UI which asks the user for confirmation if he really wants to close the window if there's still a running process. According to the GTK documentation returning true in the delete-event handler should do the job but it doesn't work for me as the window closes nevertheless.

I reduced it to a minimal working example which produces the same problem.

void main(string[] args)
     import std.stdio;
     import gdk.Event;
     import gtk.Main;
     import gtk.MainWindow;
     import gtk.Widget;


     MainWindow window = new MainWindow("Test of window close button");
     window.setDefaultSize(200, 200);
     window.addOnDelete(delegate bool (Event, Widget) {
         writeln("Close button called");
         return true; // This should prevent the window from closing, but it doesn't


I'm using GtkD 3.8.5. It would be very nice if someone could help me with this. Many thanks :)

Replace MainWindow with Window and it should work.

I'm not sure what the MainWindow class was trying to accomplish but it
sets up a handler for the delete event that quits the gtk mainloop, and
that causes the application to close.