I’m trying to use the context menu with a tree.
Tree creates OK, have d-n-d working, etc.
Adding context menu as follows:
----------------------------------------------------
var ctxtMenu = new dhtmlXContextMenuObject(‘120’,0,"…path-to-imgs");
var item = new dhtmlXMenuItemObject(“ctxtInsert”,“Insert”,"","",“contextMenu”);
ctxtMenu.menu.addItem(ctxtMenu.menu,item);
item = new dhtmlXMenuItemObject(“ctxtDelete”,“Delete”,"","",“contextMenu”);
ctxtMenu.menu.addItem(ctxtMenu.menu,item);
ctxtMenu.setContextMenuHandler(function(menuId,treeId){
alert(menuId);
});
ctxtMenu.setOnShowMenuHandler(function(treeId){
tree.selectItem(treeId);
});
tree.enableContextMenu(ctxtMenu);
------------------------------------------------------
On right-click the menu appears, but behind the tree node text. Then I can’t click a menu item because the click goes to the tree instead.
Have I done something wrong? How do I get the menu on top?
Ed
Most probably the issue caused by used z-indexes. If you are initialized tree in some kind of absolute positioned HTML container it possible that it have z-index greater than one of context menu.
To resolve problem you can add next command to context menu initialization.
var ctxtMenu = new dhtmlXContextMenuObject(‘120’,0,"…path-to-imgs");
ctxtMenu.menu.setZIndex(999); // or some other big value