[Gtk-sharp-list] Newbie cuestion: delete_event of a window
Raúl Moratalla
raul.moratalla@ono.com
Fri, 16 Jul 2004 20:10:03 +0200
Fredrik Nilsson escribió:
>On fre, 2004-07-16 at 19:35 +0200, Raúl Moratalla wrote:
>
>
>>Hi everybody:
>>
>>I'm using the documentation of mono and there is the following example
>>of a messagedialog:
>>
>>MessageDialog md = new MessageDialog (parent_window,
>> DialogFlags.DestroyWithParent,
>> MessageType.Question,
>> ButtonsType.YesNo, "Are you sure you want to quit?");
>>
>>ResponseType result = (ResponseType)md.Run ();
>>
>>if (result == ResponseType.Yes)
>> Application.Quit();
>>else
>> md.Destroy();
>>
>>This code is launched in the signal delete_event of a window but, after
>>this the window of the application is deleted. What should I do for
>>avoid it?
>>
>>Best regards,
>>
>>Raúl
>>
>>
>
>Hi Raúl,
>
>You need to set the RetVal property of the eventargs, like this:
>
>void on_window_delete_event (object o, DeleteEventArgs args) {
> // Show your dialog here
>
> if (result == ResponseType.Yes) {
> Application.Quit();
> args.RetVal = false; // <-- Destroy window
> } else {
> md.Destroy();
> args.RetVal = true; // <-- Don't destroy window
> }
>}
>
>/Fredrik
>
>
>
>
>
Thanks Fredrik for the information and your patience with me. I didn't
know about that property but it is used in the glade template that
creates monodevelop.
The documentation provided by mono is still a bit incomplete. I'm going
to search in google, but do you know a good site where to find
information and documentation about MONO/GTK#?
Regards,
Raúl