Categories | Question details Back To List | ||
problems with openAt() method of context menu Hello, while doing drag&drop processing inside a dhtmlxTree component it's a check of permissions perfomed which is to show a context menu over the targed node of the tree. but when i invoke openAt() function the menu doesn't show up ( here is some source code: function initTree_universe(treeDiv){ ... universeTree.attachEvent("onDrag",onUniverseDrag); ... } function initPopupMenu_universe(){ //init context menu dragMenu=new dhtmlXContextMenuObject(80,40); dragMenu.menu.setZIndex(10000); dragMenu.menu.loadXML("contextMenu.xml"); dragMenu.setContextMenuHandler(onPopupItemChoosen); dragMenu.setContextZone('treebox', 1); } function onUniverseDrag(sid,tid,ad){ ... //alert("{x,y}: "+iMousePosX +", "+iMousePosY); dragMenu.openAt(iMousePosX,iMousePosY,1,true); ... } but what is more strange, if I uncomment this row: //alert("{x,y}: "+iMousePosX +", "+iMousePosY); the menu shows up pretty fine after OK button of alert dialog is clicked Do you know the way to fix it? TIA Answer posted by Support on Jun 17, 2008 03:49 The problem caused by event processing order , the situation is next onmousedown ( DOM ) onDrag ( Tree ) context menu shown onclick ( DOM ) - this event generated as continuation of onmousedown context menu hidden - this is default behavior of context menu, it is hide self on any click inside document. To resolve issue just open menu through timeout, 1ms delay is to short to be visible, but enough to resolve dom events problem. window.setTimeout(function(){ dragMenu.openAt(iMousePosX,iMousePosY,1,true); },1); |