[Gtk-sharp-list] How to show dialog modal and wait for it?
Maciej Pilichowski
bluedzins at wp.pl
Fri Dec 25 07:38:44 EST 2009
Hi,
On Friday 25 December 2009 11:47:37 Rafa wrote:
> Are you sure the error is there?
Well, I don't know. In my case I have FileChooseButton to select a
file. From code I call its method (on an object) SetFilename. But the
event SelectionChanged is called twice -- first with null filename,
the second time with proper one.
And in handler of this event I load data from selected file and show
the message dialog. Since the event is triggered twice I have two
message dialogs.
Even if FileChooseButton has a bug (very odd double event) calling
modal dialog should stop processing events in main dialog -- at least
I would like to achieve this.
Below is shortened code:
public partial class MainWindow : Gtk.Window
{
protected virtual void OnFilechooserbuttonSelectionChanged
(object sender, System.EventArgs e)
{
var md = new MessageDialog(this, DialogFlags.Modal,
MessageType.Error, ButtonsType.Close, "Some error");
md.Run();
md.Destroy();
}
public MainWindow () : base(Gtk.WindowType.Toplevel)
{
Build ();
var chooser = new FileChooserButton("title",FileChooserAction.Open);
chooser.SelectionChanged += OnFilechooserbuttonSelectionChanged;
chooser.SetFilename("test");
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
}
Cheers,
More information about the Gtk-sharp-list
mailing list