From f60032cc4a66084144b5bf9ced40c60fea4b3d11 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Fri, 13 Feb 2015 13:38:07 +0300 Subject: [PATCH] implement drag&drop files to application window - issue #24 --- src/dlangide/ui/commands.d | 8 +++++++- src/dlangide/ui/frame.d | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d index 94de07a..bbe2971 100644 --- a/src/dlangide/ui/commands.d +++ b/src/dlangide/ui/commands.d @@ -4,7 +4,6 @@ public import dlangui.core.events; import dlangui.widgets.editors; enum IDEActions : int { - None = 0, //ProjectOpen = 1010000, FileNew = 1010000, FileNewWorkspace, @@ -43,6 +42,12 @@ enum IDEActions : int { ProjectFolderRenameItem, } +__gshared static this() { + // register editor action names and ids + registerActionEnum!IDEActions(); +} + + const Action ACTION_PROJECT_FOLDER_ADD_ITEM = new Action(IDEActions.ProjectFolderAddItem, "MENU_PROJECT_FOLDER_ADD_ITEM"c); const Action ACTION_PROJECT_FOLDER_OPEN_ITEM = new Action(IDEActions.ProjectFolderOpenItem, "MENU_PROJECT_FOLDER_OPEN_ITEM"c); const Action ACTION_PROJECT_FOLDER_REMOVE_ITEM = new Action(IDEActions.ProjectFolderRemoveItem, "MENU_PROJECT_FOLDER_REMOVE_ITEM"c); @@ -87,3 +92,4 @@ const Action ACTION_HELP_ABOUT = new Action(IDEActions.HelpAbout, "MENU_HELP_ABO const Action ACTION_WINDOW_CLOSE_ALL_DOCUMENTS = new Action(IDEActions.WindowCloseAllDocuments, "MENU_WINDOW_CLOSE_ALL_DOCUMENTS"c); const Action ACTION_CREATE_NEW_WORKSPACE = new Action(IDEActions.CreateNewWorkspace, "Create new workspace"d); const Action ACTION_ADD_TO_CURRENT_WORKSPACE = new Action(IDEActions.AddToCurrentWorkspace, "Add to current workspace"d); + diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index da2fbfd..fed2eaa 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -66,6 +66,7 @@ class IDEFrame : AppFrame { this(Window window) { super(); window.mainWidget = this; + window.onFilesDropped = &onFilesDropped; } override protected void init() { @@ -615,6 +616,13 @@ class IDEFrame : AppFrame { Builder op = new Builder(this, currentWorkspace.startupProject, _logPanel, currentWorkspace.buildConfiguration, buildOp, false); setBackgroundOperation(op); } + + void onFilesDropped(string[] filenames) { + //Log.d("onFilesDropped(", filenames, ")"); + for (int i = 0; i < filenames.length; i++) { + openSourceFile(filenames[i], null, i == 0); + } + } } Widget createAboutWidget()