TreeView Widget Drag and Drop Support

Sean Cole (Pi) sean at
Tue Mar 30 20:06:19 EDT 2021

Hi Henry,

I often take the widgets, like TreeView, and add in other message
responders like this. It's real easy to do?

Just make a copy of the widget folder from the LC Tools Folder
( and
into your own Livecode extensions folder (mine is in ~/Documents/My
LiveCode/Extensions/ or my dropbox folder somewhere). Rename the folder
from com.livecode. to com.mine. or something. Then open treeview.lcb in
BBEdit or TextEdit, etc, from the copy folder. Line 88, change widget
com.livecode.widget.treeview to use the new folder name you gave.

Next, search for 'onMouseUp'. you should find:

public handler onMouseLeave() returns nothing
put 0 into mHoverRow
redraw all
end handler

Before that in the code, add in your other handlers (OnDragDrop, etc) using
the same syntax. No need to use the put or redraw messages of course. Look
in the dictionary, lcb section, to check the handler names to use.

Then, open the manifest.xml from the same folder. Line 2, again
change <name>com.livecode.widget.treeview</name> to use the new folder name
and Line 3 to something a little more unique. Then again search for
onmouseup. You will see:

<handler name="OnMouseUp" parameters="" return="nothing"/>

Again, follow the syntax adding in the lines for the handler.

Look through the other files in the folder and change if you wish but it is
not essential.

Now in LC, open the extension builder and use the 'open existing..' button
to navigate to the folder you created. Then, from the bottom, the install
button will build it into the toolbar.

Now you have a customised version. Make sure you add your replacement
widget in the standaloneSettings>Inclusions before building your

All the best


On Wed, 31 Mar 2021 at 00:26, HENRY LOWE via use-livecode <
use-livecode at> wrote:

> I am using the LC TreeView widget to implement a sidebar containing a
> hierarchical menu in a MacOS app. The widget seems well suited for this
> purpose and I have successfully created a facsimile of the standard sidebar
> that is used increasingly in both MacOS and iPadOS apps. However, I need to
> drag rows from a data grid table to a TreeView widget row in the sidebar
> but the current implementation of the TreeView widget does not report the
> TreeView widget row (element) where the drop occurred. A TreeView widget
> message, such as 'ActionDragDrop pPath’ where pPath is the path to the
> element that was ‘dropped on’ would be incredibly helpful. I have
> implemented a workaround method off drag and drop to the widget but it
> occasionally breaks.
> Looking at the LiveCode Builder documentation, widgets can support the
> following messages related to drag and drop functionality:
> OnDragDrop, On DragEnter, OnDragFinish, OnDragLeave, On DragMove, On
> DragStart.
> These messages are not currently supported in the TreeView widget LCB
> source. Adding them would make this incredibly useful widget even more
> powerful.
> Another issue that I encountered when using the TreeView widget to
> implement a sidebar hierarchical menu was that clicking on a row in the
> TreeView widget toggles the row’s hilite state  - click on an item and it
> hilites, click on it again and it unhilites. While this may be standard
> behavior for a list, in a menu clicking on a hilited row should not change
> the row’s hilite state. It should remain hilited. Only clicking on another
> row (menu item) should unhilite a row and then hilite the selected row. It
> would be great to have a ’togglehilite’ TreeView property. If true the
> TreeView would toggle a row’s hilite state as it does now, while if false
> it would not.
> Any thoughts?
> Henry
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:

More information about the use-livecode mailing list