TreeViewNodeAt ( treeview,x,y )

Parameters

treeview - tree view gadget

x - horizontal position in logical pixels, from the tree view's left edge

y - vertical position in logical pixels, from the tree view's top edge

Description

Returns the tree view node whose row is at a point, or 0 over empty space or a scroll bar.

The whole row counts, including its indent and expand button, just as a click there selects the node. Collapsed branches hide their children, so only visible rows are ever returned.

Use it to find the node under a right-click. A tree posts a $201 mouse-down event with EventData()=2 for the right button, and EventX() and EventY() are already in the logical pixels this command expects, so a context menu can act on the row that was clicked rather than on the old selection:

If EventID()=$201 And EventSource()=tree And EventData()=2 Then
    node=TreeViewNodeAt(tree,EventX(),EventY())
    If node Then
        SelectTreeViewNode node
        ShowPopupMenu menu,tree,EventX(),EventY()
    EndIf
EndIf

The World Editor opens its object menu this way from its Scene hierarchy.


See also: SelectedTreeViewNode, SelectTreeViewNode, TreeViewNodeText, ShowPopupMenu.

Index