FormDropFiles sends data to an object on the Form also lazarus / 31-LCL ---------------------------------------------------------------------- fedkad · 2018-02-27 14:33 To drop files names to an application I use the main Form's onDropFiles event. This event, when fired, will give an array of file names being dragged-and-dropped to the application window like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainForm.FormDropFiles(Sender: TObject;  const FileNames: array of String);begin  // process FileNames array as you like!end;                      However, in Linux, a memo component that resides on the form will also have the text in FileNames array appended to it (if the user drops the mouse pointer on this memo of course). This behavior is strange, because the memo component is not prepared to accept drop events. Such a behavior is not present in Windows. ---------------------------------------------------------------------- Leledumbo · 2018-02-27 18:54 Could be DE/widgetset specific. At least it doesn't happen on my KDE Plasma using Qt backend. ---------------------------------------------------------------------- fedkad · 2018-02-28 09:26 I have this problem both in Lazarus 1.8.0 and 1.9.0 (latest SVN). OS is Ubuntu Linux 17.10 / x86_64-linux-gtk2. ---------------------------------------------------------------------- Thaddy · 2018-02-28 09:37 Quote from: fedkad on February 27, 2018, 03:33:52 pmSuch a behavior is not present in Windows. Well that seems so, but isn't the case: windows just has a better understanding and separation of clipboard formats. Once you ask different formats even Windows has the same behavior. ---------------------------------------------------------------------- fedkad · 2018-02-28 09:47 This is a drag and drop operation from the file manager towards the application. I couldn't understand its relationship with the clipboard Thaddy. ---------------------------------------------------------------------- jamie · 2018-02-28 22:20 In windows a chunk of global memory is allocated which contains the list of file names in it.  The WM_DropFiles is received which has the handle to this memory chunk  DragQueryFile and DragQueryPoint are used to examine the memory and drop location.  Last time I knew the clipboard isn't used. ---------------------------------------------------------------------- fedkad · 2018-03-01 10:50 Create a new project and a new form.Add a memo and a label to the form.Enable the AllowDropFiles property of the form.Add the following code to the OnDropFiles event of the form: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String  );var  i : Integer;begin  label1.Caption := '';  for i:=low(FileNames) to high(FileNames) do    label1.Caption := label1.Caption + LineEnding + FileNames[i]end; Then run the application and  drag-drop some files from Nautilus (file manager) to the application. Label1 should display their names. If you drop the files to Memo1 instead of an empty area on the form, a string containing the file names will be added to Memo1 contents. For more strange things do this: Select some text from Memo1 and try to drag-drop it somewhere within Memo1 (something that you cannot do if the application were run in Windows). The contents will be moved, but some garbage will be displayed in Label1 (see attached screenshot), because the OnDropFiles event of the form is fired! ---------------------------------------------------------------------- Bart · 2018-03-01 18:12 I cannot reproduce that with Lazarus trunk on Linux Mint 18.2. If I build for GTK then I cannot drop anything on the TMemo, only on the Form. If I build for QT, I can drop anywhere, but it only fires the Form's OnDropFiles: nothing at all happens with the TMemo. Note: I have Dolphin as filemanger, not Nautilus. Bart ---------------------------------------------------------------------- Leledumbo · 2018-03-01 18:13 Quote from: fedkad on March 01, 2018, 11:50:52 amFor more strange things do this: Select some text from Memo1 and try to drag-drop it somewhere within Memo1 (something that you cannot do if the application were run in Windows). The contents will be moved, but some garbage will be displayed in Label1 (see attached screenshot), because the OnDropFiles event of the form is fired! Sounds like a gtk2 bug. Try reproducing with qt, just to make sure the culprit is indeed the widgetset. With that checked, file a bugreport against gtk2 widgetset. ---------------------------------------------------------------------- fedkad · 2018-03-04 10:00 When I try to compile for anything different than the default gtk2 (in Project Options...|Additions and Overrides) I get a bunch of compile and / or link errors. I even tried, Clean up and Build. So, I am only able to test with gtk2. I opened a bug report ( https://bugs.freepascal.org/view.php?id=33292 ), but it is still in "new" status. ---------------------------------------------------------------------- Bart · 2018-03-04 14:05 You need to install the fpc bindings for QT. Look in the wiki for QT, there's a link there that explians howto. Even I succeeded in doing that on 2 successive Linux distro's (3, because of dying hardware). Bart