[Gtk-sharp-list] How to show dialog modal and wait for it?
christian_hoff at gmx.net
Fri Dec 25 03:52:46 EST 2009
Maciej Pilichowski wrote:
> I know, the lamest question there can ever be, but to my surprise I
> cannot achieve this simple goal with Gtk#.
> I copied the message dialog example code from the web, it should
> create dialog, show it (so far so good) and wait for it to close. But
> it does not wait -- the main code continue executing.
> MessageDialog md = new MessageDialog
> (this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close,
> "some error");
> md.Run ();
I think that you're missing a call to hide the dialog window. If you
insert a md.Hide (); statement after the md.Run (); line everything
should work fine.
By now I would expect that your code stops executing until a button is
pressed on the dialog, but that afterwards the dialog might remain shown.
If it still doesn't work out: What is the Gtk.Response type returned by
"(Gtk.ResponseType) dialog.Run ();"? Does the whole thing work if you
use "null" as the parent window (first argument to constructor)?
Hope this helps,
> // <-- here, I would like to stop and wait for dialog to be closed
More information about the Gtk-sharp-list