简体   繁体   English

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

[英]Overriding GTK Window Close Event to Show a Message

I'm trying to override the Gtk.Window close event so that a Dialog is displayed to the user if a certain Boolean value is set.Inspite the Boolean Value being true my application Quits without showing the Dialog.I have tried printing out the Boolean value.It is correct. 我正在尝试覆盖Gtk.Window关闭事件,以便在设置了某个布尔值的情况下向用户显示一个对话框。尽管布尔值是true,但我的应用程序在不显示Dialog的情况下退出了。值。这是正确的。

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;
            }
    }

The signal handler return value should be true in the if-case (to stop the default handler from being invoked). 在if情况下,信号处理程序的返回值应为true(以阻止调用默认处理程序)。 In the else-case you should probably just return false to allow default handler to run and not call Quit() yourself. 在其他情况下,您应该只返回false即可运行默认处理程序,而不自己调用Quit()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM