DHTMLX Docs & Samples Explorer

### Event Handling: CAS State (Contextual Menu)

Source

    <link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxmenu_dhx_skyblue.css">
    <script src="../../codebase/dhtmlxcommon.js"></script>
    <script src="../../codebase/dhtmlxmenu.js"></script>
    <script src="../../codebase/ext/dhtmlxmenu_ext.js"></script>

    <div style="height: 380px; position: relative;">
        <div id="zoneA" style="position: absolute; left:  50px; top: 100px; width: 200px; height: 60px; border: #C1C1C1 1px solid; background-color: #E7F4FF;"></div>
    </div>
    <div id="ta" style="width: 500px; height: 160px; border: #909090 1px solid; overflow: auto; font-size: 10px; font-family: Tahoma;"></div>

    <br>
    <script>var menu = new dhtmlXMenuObject();
    menu.setIconsPath("../common/imgs/");
    menu.renderAsContextMenu();
    menu.loadXML("../common/dhxmenu.xml?e=" + new Date().getTime());
    menu.addContextZone("zoneA");
    //;
    menu.attachEvent("onClick", function(id, zoneId, casState) {
        document.getElementById("ta").innerHTML += "<b>onClick</b> '" + menu.getItemText(id) + "' was clicked, ctrl: " + (casState["ctrl"] ? "<b>true</b>": "false") + ", alt: " + (casState["alt"] ? "<b>true</b>": "false") + ", shift: " + (casState["shift"] ? "<b>true</b>": "false") + "<br>";
    });
    menu.attachEvent("onRadioClick", function(gruop, checked, clicked, zoneId, casState) {
        document.getElementById("ta").innerHTML += "<b>onRadioClick</b> '" + menu.getItemText(clicked) + "' was clicked, ctrl: " + (casState["ctrl"] ? "<b>true</b>": "false") + ", alt: " + (casState["alt"] ? "<b>true</b>": "false") + ", shift: " + (casState["shift"] ? "<b>true</b>": "false") + "<br>";
        return true;
    });
    menu.attachEvent("onCheckboxClick", function(id, state, zoneId, casState) {
        document.getElementById("ta").innerHTML += "<b>onCheckboxClick</b> '" + menu.getItemText(id) + "' was clicked, ctrl: " + (casState["ctrl"] ? "<b>true</b>": "false") + ", alt: " + (casState["alt"] ? "<b>true</b>": "false") + ", shift: " + (casState["shift"] ? "<b>true</b>": "false") + "<br>";
        return true;
    });</script>