From d0450816437c0f1dc7d51b97cf68bf8b374777fd Mon Sep 17 00:00:00 2001 From: Markus Date: Wed, 3 Mar 2010 17:56:05 +0000 Subject: [PATCH] Added support for dragging files. Not tested at UNIX-based/compatible platforms but it should work just as good as in any other platform. It also takes care of the Windows fileswapping bug, of OpenInNewTab = false and some other kewl stuff. Besides I can now actually say I coded on Simba ;) Markus git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@576 3f818213-9676-44b0-a9b4-5e4c4e03d09d --- trunk/Projects/SAMufasaGUI/testunit.lfm | 6 +++-- trunk/Projects/SAMufasaGUI/testunit.pas | 33 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/trunk/Projects/SAMufasaGUI/testunit.lfm b/trunk/Projects/SAMufasaGUI/testunit.lfm index 4c82325..f027483 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.lfm +++ b/trunk/Projects/SAMufasaGUI/testunit.lfm @@ -1,9 +1,10 @@ object Form1: TForm1 - Left = 273 + Left = 433 Height = 555 - Top = 233 + Top = 224 Width = 739 ActiveControl = ScriptPanel + AllowDropFiles = True Caption = 'THA FUKING SIMBA' ClientHeight = 535 ClientWidth = 739 @@ -12,6 +13,7 @@ object Form1: TForm1 OnClose = FormClose OnCreate = FormCreate OnDestroy = FormDestroy + OnDropFiles = FormDropFiles OnShortCut = FormShortCuts LCLVersion = '0.9.29' Visible = True diff --git a/trunk/Projects/SAMufasaGUI/testunit.pas b/trunk/Projects/SAMufasaGUI/testunit.pas index 4b08e40..8ba1d7b 100644 --- a/trunk/Projects/SAMufasaGUI/testunit.pas +++ b/trunk/Projects/SAMufasaGUI/testunit.pas @@ -243,6 +243,7 @@ type procedure editSearchListKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure editSearchListKeyPress(Sender: TObject; var Key: char); + procedure FormDropFiles(Sender: TObject; const FileNames: array of String); procedure FunctionListChange(Sender: TObject; Node: TTreeNode); procedure FunctionListEnter(Sender: TObject); procedure FunctionListExit(Sender: TObject); @@ -1421,6 +1422,38 @@ begin end; end; +procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String + ); +var + response, i : integer; + OldFileSetting : string; +begin + if (length(FileNames) = 1) then + begin + LoadScriptFile(FileNames[0]); //One file saves us some work + exit; + end; + if (length(FileNames) > 5) then //> 5 seems nice to me, cant imagine you want to open that many scripts on a regular base + response := MessageDlg('Are you sure you want to open '+inttostr(length(filenames))+ + ' scripts?', mtConfirmation, mbYesNo, 0); + case response of + IDNO: exit; + end; + //Its plain stupid opening all of those files in just one tab -.- + OldFileSetting := SettingsForm.Settings.GetKeyValue('Settings/Tabs/OpenScriptInNewTab'); + SettingsForm.Settings.SetKeyValue('Settings/Tabs/OpenScriptInNewTab', 'True'); + {$IfDef WINDOWS} + //Fix for the really old Windows kernel bug which probably will never be fixed + for i := 1 to high(filenames) do + LoadScriptFile(FileNames[i]); + LoadScriptFile(FileNames[0]); + {$Else} //in this case its tolerable as Windows is the only OS with this bug + for i := 0 to high(filenames) do + LoadScriptFile(FileNames[i]); + {$EndIf}; + SettingsForm.Settings.SetKeyValue('Settings/Tabs/OpenScriptInNewTab', OldFileSetting); +end; + procedure TForm1.FunctionListChange(Sender: TObject; Node: TTreeNode); var MethodInfo : TMethodInfo;