当窗口关闭时,系统会要求用户保存他们编辑的文件。他们还应该有一个取消退出应用程序的选项。
在WPF中,我可以将CancelEventArgs.Cancel属性设置为true来完成此操作。在Gtk#中是否有等效的/解决方法?
发布于 2009-06-29 08:59:06
您需要将DeleteEventArgs.RetVal设置为true,而不是false。从relevant Mono documentation
要防止Gtk.Window关闭,请将Gtk.DeleteEventHandler的Gtk.DeleteEventArgs.RetVal设置为true。
发布于 2009-06-26 17:06:22
在谷歌快速搜索中找到了这个python示例(link):
# When the window is requested to be closed, we need to check if they have
# unsaved work. We use this callback to prompt the user to save their work
# before they exit the application. From the "delete-event" signal, we can
# choose to effectively cancel the close based on the value we return.
def on_window_delete_event(self, widget, event, data=None):
if self.check_for_save(): self.on_save_menu_item_activate(None, None)
return False # Propogate event希望这能有所帮助。
https://stackoverflow.com/questions/1037414
复制相似问题