Notifications
Clear all

[Closed] How to disable the .net Treeview doubleclick expand/contract node?

Hi all!

I am trying to do some custom action with a dotnet treeview when a node is double-clicked. The problem is that even when I don’t have my own doubleclick event handler, the Treeview uses the double-click to automatically expand or contract an expandable node. 🙁 Is there a way to turn off this behavior? It would be ideal if the nodes would only expand/contract if the +/- box on the node were clicked, and the double-click could be for the custom action.

Thank for any help!

3 Replies

Unless this problem has no any decision?

On one of forums of programmers I have found the decision of this problem.
But, unfortunately, this decision is written in C# language, but I should write it on maxscript. Help me, please – how to convert this code in maxscript?

Apparently OnNodeMouseDoubleClick() is not called in the WM_LBUTTONDBLCLK handler for TreeView at all . . . it’s called in the LBUTTONUP handler. So, The following is what’s at that site:

protected override void DefWndProc(ref Message m) {
        if (m.Msg == 515) { /* WM_LBUTTONDBLCLK */
        }
        else
            base.DefWndProc(ref m);
    }

If you want to halt handling to the left of the node, then in OnNodeMouseDoubleClick() do the following:

if (e.X >= e.Node.Bounds.Left) {
    return;
}
 lo1

I don’t think there is a way in maxscript to override a protected method without creating a c# class which inherits from treeview.

i know at least three ways how to stop auto expand/collapse.
here is a less dotnetty and not c-sharpy ;):


try(destroydialog tv_rol) catch()
rollout tv_rol "TreeView Test" width:200 height:200
(
	dotnetcontrol tv "TreeView" width:200 height:200 pos:[0,0] 
	
	local doubleClicked = off
	on tv BeforeCollapse s e do
	(	
		e.cancel = doubleClicked
	)
	on tv BeforeExpand s e do
	(	
		e.cancel = doubleClicked
	)
	on tv MouseDown s e do
	(
		node = s.GetNodeAt e.location
		doubleClicked = (node != undefined) and (e.clicks > 1)
	 )
	on tv_rol open do
	(
		node = tv.nodes.Add "Root"
		item = node.nodes.Add "Child"
	)
)
createdialog tv_rol