Question

I have a dialogue in GTK# that gets opened by a mouse click, and after clicking a button in it, the dialogue should be closed again. Do I have to call both methods Hide() and Destroy() on the window?

Here is my code to launch the dialogue:

protected virtual void ConfigureDialogue (object sender, System.EventArgs e)
{
    MyConfigWindow myConfWindow = new MyConfigWindow ();
    this.Sensitive = false;
    myConfWindow.Run ();
    this.Sensitive = true;
}

And here is the relevant part of the config window:

public partial class MyConfigWindow  : Gtk.Dialog
{

    public MyConfigWindow ()
    {
        this.Build();
    }

    protected virtual void onSave (object sender, System.EventArgs e)
    {
        this.Hide();
        this.Destroy ();
    }
}

When I only call this.Destroy () the main window gets sensitive again (therefore myConfWindow.Run () has ended), but the dialogue is still visible.

Was it helpful?

Solution

Your missing the destroy call in the ConfigureDialog procedure ...

  this.Sensitive = false; 
  result = myConfWindow.run();
  if (result == gtk.RESPONSE_CLOSE:)
    myConfWindow.destroy();
  this.Sensitive = true;

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top