callback
The command procedure to be executed when the mouse rests on a treenode within the tree window. The window identifier and the treenode are passed to the procedure as parameters.
Typically this procedure is used to set a context menu specific to the particular treenode, so that a subsequent right-click of the mouse will invoke a suitable popup menu. See the example below.
This procedure is not called for every movement of the mouse but only when the movement has resulted in a change of treenode under the mouse. For this reason a treenode of null may be passed to the procedure when the mouse is no longer over a treenode.
window.track(<window>,<treenode>)
Consider a tree window with nodes which have different context menus. We can create the procedures which form the popup menus beforehand to safe processing at mouse-click time, e.g.
procedure cxtmen { args w=window pulldown { 0: 'Action' 1: '-' 2: 'Play Audio' { play_audeo(w.context_node) } 3: 'Play Video' { play_video(w.context_node) } } }
The window element w.context_node is used to pick up the node which invoked the context menu.
The .track procedure would assign the relevant callback when the mouse passes over the treenode, e.g.
mytreewin.track = { args w=window, tn=treenode # If the mouse is over a valid treenode, set .exec callback which will invokes # the above menu on a subsequent right-click. # If we are not over a valid treenode, set the .exec to null, # meaning take no action. if (tn) w.exec = cxtmen else w.exec = null }