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?");

                try
                {
                        if ((!docTextView.Buffer.Modified) || 
(WarningMesgDlg.Run() == (int)
ResponseType.Yes))
                        {
                                Application.Quit ();
                                a.RetVal = true;
                        }
                }
                finally
                {
                        WarningMesgDlg.Destroy();
                }
        }

... 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.

_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to