覆盖GTK窗口关闭事件以显示消息

时间:2015-10-21 02:01:42

标签: c# xamarin mono gtk gtk#

我试图覆盖Gtk.Window关闭事件,以便在设置某个布尔值时向用户显示对话框。尽管布尔值为true,但我的应用程序退出而没有显示Dialog.I有尝试打印出布尔值。这是正确的。

protected void OnDeleteEvent (object sender, DeleteEventArgs a)
    {
            Console.WriteLine (bval);
            if (bval == true) { 

                mynot notification=new mynot(this); 
                notification.Show (); 

            }
            else
            {
                Gtk.Application.Quit ();
                a.RetVal = true;
            }
    }

1 个答案:

答案 0 :(得分:1)

if-case中的信号处理程序返回值应为true(以阻止调用默认处理程序)。在else-case中你应该只返回false以允许默认处理程序运行而不是自己调用Quit()。