在Gtk#中,我可以为“摧毁”事件挂钩一个处理程序,但它永远不会被调用。这个应用程序不会打印任何东西Gtk文档说,只有在设置了特定标志时才会发送“destroy”事件,并且还表示该标志由Gdk自动设置。Gtk#摧毁事件
这是令人沮丧的,因为它基本上与原本正常工作的Gtk +代码相同。我怎么知道什么时候打电话Application.Quit()
,除了听“摧毁”事件呢?
using System;
using Gtk;
public class MainWindow {
public static void Main(string[] args)
{
Application.Init();
Window win = new Window("Test");
win.Resize(200, 200);
win.DestroyEvent += new DestroyEventHandler(OnDestroy);
win.ShowAll();
Application.Run();
}
private static void OnDestroy(object o, DestroyEventArgs args)
{
Console.WriteLine("OnDestroy");
}
}
P.S.我对“删除”事件不感兴趣。
你为什么不对DELETE事件感兴趣? – ptomato
@ptomato:Gtk文档:“如果用户请求顶层窗口关闭,则发出删除事件信号” - 我想知道窗口关闭的时间,而不是用户请求的时间。 –