[Gtk-sharp-list] How do I keep main window from closing?

bdubu bwb at fireflysoftware.com
Mon Jul 20 18:51:52 EDT 2009

I have a TextView on my main window.  I don't want to be able to close the
main window if the text in this TextView has been modified but not yet saved
to disk.  I realize I can check the control's Buffer.Modified property and
that this should likely be done in the main windows's OnDeleteEvent handler
but I don't know how to make this work.  I took a WAG and tried this...

	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
		MessageDialog WarningMesgDlg = new MessageDialog (this, 
		DialogFlags.DestroyWithParent, MessageType.Warning, 
		ButtonsType.YesNo, "Abandon changes?");

			if ((!docTextView.Buffer.Modified) || (WarningMesgDlg.Run() == (int)
				Application.Quit ();
				a.RetVal = true;

... but the main window closes even though the Modified property is true and
I answer "no" to the dialog's question, "Abandon changes?".  Can someone
shed some light on how I should go about this?  Thanks!

View this message in context: http://www.nabble.com/How-do-I-keep-main-window-from-closing--tp24578770p24578770.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.

More information about the Gtk-sharp-list mailing list