DHTMLX Docs & Samples Explorer

Index
dhtmlxmenu
Event Handling

## onCheckboxClick Event

By default this event changes the state of the clicked checkbox item. The visible sub-polygon won't be hidden after this action. onCheckboxClick event can call user-defined handler (if there is any) and pass the following parameters:

- id - id of the clicked checkbox item;
- state - state of the clicked checkbox item. Defines whether the item is checked or not;
- zoneId (only for Contextual Menu) - id of the contextual menu zone;
- casState - whether the key “Ctrl”, “Alt”, or “Shift” was pressed with click or not.

            menu.attachEvent("onCheckboxClick", function(id, state, zoneId, casState){
                ...
                // user-defined handler
                // ctrl
                if (casState["ctrl"] == true) {
                        // ctrl key was pressed with click
                } else {
                        // ctrl key was not pressed with click
                }
                // alt
                if (casState["alt"] == true) {
                        // alt key was pressed with click
                } else {
                        // alt key was not pressed with click
                }
                // shift
                if (casState["shift"] == true) {
                        // shift key was pressed with click
                } else {
                        // shift key was not pressed with click
                }
                return true;
            });

When the user attaches a user-defined handler to this event, the state of the item can no longer be changed automatically. The user can control this by returning true|false from a user-defined handler. That's why, return true should be added after a user-defined handler in order to let the script know that the state of the item should be changed.