[Gtk-sharp-list] Problem with DeleteEvent

Fredrik Nilsson jymdman@home.se
Thu, 19 Aug 2004 22:10:57 +0200


On tor, 2004-08-19 at 17:58 +0100, miguel díaz wrote:
> Hi again,
> i fear it does not work, now i dont get a console
> warning, but the app closes without showing the my
> dialog; may be the destroy event occurs after the
> delete event, but i cant find a method or signal like
> 'closed' in the documentation, here what i tried,
> thanks:
> 
> this.appWindow.DestroyEvent += new
> Gtk.DestroyEventHandler (OnDestroyEvent);
> 
> public void OnDestroyEvent (object obj,
> DestroyEventArgs args) 
>         {
>             if(contentsModified == true){
>             	new WarningDialog();
>             	args.RetVal = false;
> 			}
> 			else{
> 				args.RetVal = true;
> 
> 

Hi Miguel,

This piece of code should work for you:


this.appWindow.DeleteEvent += new Gtk.DeleteEventHandler
(OnDeleteEvent);


void OnDeleteEvent (object o, DeleteEventArgs args) {
        if (contentsModified == true) {
		new WarningDialog();
	}

        Application.Quit();
        args.RetVal = false;
}

The problem might be in WarningDialog(), how do you display your dialog?
If it's a normal window, the program will quit right away.. 
If that is the case, try to use use a MessageDialog and call Run() on
the dialog...

/Fredrik