代码之家  ›  专栏  ›  技术社区  ›  Residuum

在GTK中销毁窗口#

  •  0
  • Residuum  · 技术社区  · 16 年前

    我在GTK中有一个通过鼠标单击打开的对话框,单击其中的按钮后,该对话框应再次关闭。是否必须在窗口上同时调用hide()和destroy()方法?

    下面是启动对话的代码:

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

    下面是配置窗口的相关部分:

    public partial class MyConfigWindow  : Gtk.Dialog
    {
    
        public MyConfigWindow ()
        {
            this.Build();
        }
    
        protected virtual void onSave (object sender, System.EventArgs e)
        {
            this.Hide();
            this.Destroy ();
        }
    }
    

    当我只打电话的时候 this.Destroy () 主窗口再次变得敏感(因此 myConfWindow.Run () 但对话仍然可见。

    1 回复  |  直到 16 年前
        1
  •  4
  •   Robert French    16 年前

    在configuredialog过程中缺少destroy调用…

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

    希望有帮助。