From b1d4e290573892a18f1e21e9b53a1a89e6456b56 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Fri, 13 Feb 2015 14:21:53 +0300 Subject: [PATCH] ask user to save unsaved files when closing IDE window - issue #28 implemented for win32 backend --- src/dlangide/ui/frame.d | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index 7dd0fe8..d852bcb 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -67,6 +67,7 @@ class IDEFrame : AppFrame { super(); window.mainWidget = this; window.onFilesDropped = &onFilesDropped; + window.onCanClose = &onCanClose; } override protected void init() { @@ -444,7 +445,8 @@ class IDEFrame : AppFrame { if (a) { switch (a.id) { case IDEActions.FileExit: - window.close(); + if (onCanClose()) + window.close(); return true; case IDEActions.HelpAbout: Window wnd = Platform.instance.createWindow("About...", window, WindowFlag.Modal); @@ -628,6 +630,14 @@ class IDEFrame : AppFrame { } } } + + /// return false to prevent closing + bool onCanClose() { + askForUnsavedEdits(delegate() { + window.close(); + }); + return false; + } } Widget createAboutWidget()