Recent

Author Topic: Virtual TreeView Drag & Drop to arrange nodes w/o ActiveX  (Read 3710 times)

torumyax

  • New Member
  • *
  • Posts: 34
Virtual TreeView Drag & Drop to arrange nodes w/o ActiveX
« on: February 12, 2018, 04:52:18 pm »
hello everyone,

I just want to share this.

I'm implementing D&D to move nodes in Virtual TreeView. And there is a good example here.
https://stackoverflow.com/questions/8487335/virtualtreeview-drag-and-drop-to-arrange-nodes-in-a-list

It works fine with the Lazarus port of Virtual Treeview (VirtualTreeView-Lazarus 5.5.3-r1) on Windows. However, DragDrop event requires IDataObject which uses ActiveX unit. On Ubuntu (or any Linux or non-Windows), you get compile error, naturally...

So, I spent half day trying to find a way to do it without ActiveX.

And solution was..

Code: Pascal  [Select][+][-]
  1. uses
  2. {$ifdef windows},ActiveX{$else},FakeActiveX{$endif}

and set DragType to dtVCL.
I don't think there is any documentation or wiki entries on this as of today. I hope this helps some one some day.


PS. After little bit of testing, I think I encountered a bug on both Linux and Windows. On windows, right click sometimes does not work. Some time, you have to double right click to select and show popup. On Linux(Ubuntu at least), it is bit worse. Right click some times triggers dragging.

I attached simple project to recreate the behavior.

I am well aware that the maintainer clearly states testing on Linux is limited and dtVCL is sort of deprecated option for the original Virtual Treeview. However, I like Virtual TreeView and wanna work on Linux too...


------------------------------

VirtualTreeView-Lazarus 5.5.3-r1

Windows 10:
Lazarus 1.8.0 r56594 FPC 3.0.4 x86_64-win64-win32/win64

Ubuntu 17.10
Lazarus 1.8.0 rc4+dfsg-1 FPC 3.0.2 x86_64-linux-gtk2

torumyax

  • New Member
  • *
  • Posts: 34
Re: Virtual TreeView Drag & Drop to arrange nodes w/o ActiveX
« Reply #1 on: February 14, 2018, 05:06:45 am »
just a follow up...

I just tested "dragging with DragType set to dtVCL" (VirtualTreeView-Lazarus 5.5.3-r1) on MacOS 10.03.2 High Sierra (Lazarus 1.8.0 rexported FPC 3.0.4 i386-darwin-carbon)

Right click select works, but just like on Ubuntu, it triggers dragging... Besides this, Mouse wheel scrolling is not working. It always goes back to where it was.

So, the work around for now is to disable(default) "right click select" option if you want to drag and drop.

cheers

PS. on MacOS, Kanji characters show up fine unlike on Ubuntu.
https://forum.lazarus.freepascal.org/index.php/topic,40042.0.html


------------------------------------------------
Windows 10:
Lazarus 1.8.0 r56594 FPC 3.0.4 x86_64-win64-win32/win64

Ubuntu 17.10:
Lazarus 1.8.0 rc4+dfsg-1 FPC 3.0.2 x86_64-linux-gtk2

MacOS 10.03.2 High Sierra:
Lazarus 1.8.0 rexported FPC 3.0.4 i386-darwin-carbon
« Last Edit: February 14, 2018, 06:43:10 am by torumyax »

 

TinyPortal © 2005-2018