TreeView "undocumented" features

Started by _PJ_, May 18, 2024, 10:00:32

Previous topic - Next topic

_PJ_

So I discovered some interesting features that don't seem to be mentioned at all in the docs/examples, particualrly concerning TreeView gadgets::

While WaitEvent()
    Print CurrentEvent.ToString()
   
    Select EventID()
        Case EVENT_MENUACTION
            DebugLog("Menu Select Event")
        Case EVENT_GADGETDRAG
            DebugLog("Dragging: "+GadgetText(TGadget(EventExtra())))

        Case EVENT_GADGETDROP
            DebugLog("Dropping: "+GadgetText(TGadget(EventExtra()))+" to "+GadgetText(TGadget(EventSource())))

        Case EVENT_WINDOWCLOSE
            End
    End Select
Wend
1) The STYLE parameter for CreateTreeView() Seems to operate with the following two bit-flags:
a) 1 = This flag will allow Drag & Drop (See below)
b) 2 = This flag will hide expanders (( they are shown by default ))

2) To capture Drag & Drop events [if available from Style], refer to EventID returns for EVENT_GADGETDRAG and EVENT_GADGETDROP
 EventData() Stores the MouseButton used to perform the drag. EventIX() and EventIY() contain the coordinates where the event was initiated

3) With DRAG and DROP events in the context of TreeView nodes, the identity of the "Dragged" gadget is recorded with the EventExtra() object and the target seems to be found with GadgetSource() ----    HOWEVER  -----

There does not appear to be any means to identify the TARGET NODE if trying to drop to a different NODE/TREEVIEW gadget

One workaround may be to assume it is previously selected (( null value if the 'selected node' doesn't exist or exists within a different TV. or of course, if no node selected ))

        Case EVENT_GADGETDROP
            DebugLog("Dropping: "+GadgetText(TGadget(EventExtra()))+" to "+GadgetText(SelectedTreeViewNode(treeview)))
But this is fairly awkward.