Problem with Tabbar and context menu

Hello,

We’re trying to achieve following:
A div with customized content is inserted into tabbar, after the last tab. And when user clicks(a left-click) on the div, a menu will appear.

We were able to insert the div (with id ‘_customziedDiv’), but the menu doesn’t appear with click event.

var myMenu = new dhtmlXMenuObject(); myMenu.renderAsContextMenu(); myMenu.addNewChild(myMenu.topId, 0, "open", "Open", false); myMenu.addNewChild(myMenu.topId, 1, "new", "New", false); tabbar._tabZone.onclick = function(e) { var src=e?e.target:event.srcElement; var target = tabbar._tabZone.tabbar._getTabTarget(src); if (target == null) { // Find customized div correctly // THIS LINE DOES NOT SHOW THE MENU myMenu.showContextMenu(100,200); } else { // Normal tabs. Use default logic. } };

Another observation while we were playing with the tabbar and menu, not sure if it’s related –

If a normal tab is set as context zone, the context menu appears. But if the customized div is set as context zone,the browser’s context menu
appear instead.

// WITH NORMAL TABS, WORKS $("div[tab_id='normalTab']").attr("id", "_leftCntxtZone"); myMenu.addContextZone("_leftCntxtZone"); // WITH CUSTOMIZED DIV, DOESN'T WORK myMenu.addContextZone("_customziedDiv");

Thank you!

Please, try to call the showContextMenu() with the timeout. Calling it from the onclick event occurring that click to close the context menu as these things are executing at the same time

var myMenu = new dhtmlXMenuObject(); myMenu.renderAsContextMenu(); myMenu.addNewChild(myMenu.topId, 0, "open", "Open", false); myMenu.addNewChild(myMenu.topId, 1, "new", "New", false); tabbar._tabZone.onclick = function(e) { var src=e?e.target:event.srcElement; var target = tabbar._tabZone.tabbar._getTabTarget(src); if (target == null) { // Find customized div correctly // THIS LINE DOES NOT SHOW THE MENU setTimeout(function() {myMenu.showContextMenu(100,200)}, 100) } else { // Normal tabs. Use default logic. } };

Yep, that’s it! Thanks!