onContextMenu

fires when a user clicks the right mouse button inside the Gantt chart (see the details)

void onContextMenu(string taskId,string linkId,Event e){ ... };

Parameters

taskIdstringthe event id
linkIdstringthe event id
eEventa native event object

Example

gantt.attachEvent("onContextMenu", function (taskId, linkId, event) {
    var element = event.target;
    console.log("You've clicked on the ", element)
    return true;
});

Related samples

Details

Right clicks in the Gantt chart open the default browser context menu, if there are no other conditions. In the following example a click on a task shows a DHTMLX context menu and hides the default browser context menu.

//requires DHTMLX menu component
gantt.attachEvent("onContextMenu", function (taskId, linkId, event) {
    var x = event.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,
        y = event.clientY+document.body.scrollTop+document.documentElement.scrollTop;
 
    if (taskId) {
        menu.showContextMenu(x, y);
        return false;
    }
 
    return true;
});
Back to top