Contextmenu clicking on event

Hallo.

I need contextmenu for events. So far I found

scheduler.attachEvent("onContextMenu", function (event_id, native_event_object){

but it does not solve two problems. Showing context menu only, when user right clicks on the event (everywhere else it does nothing) and hiding browsers native context menu (view source etc. )
I haven’t found any relevant information in forum or documentation. Any help appreciated.

Thank you.

you can check event_id to get info is right click occurs on event box or on empty space
also, you can block native right click event ( native DOM event object is provided as second parameter ) to prevent native context menu from appearing.

        var menu = new dhtmlXMenuObject();
        menu.renderAsContextMenu();
        menu.addContextZone("scheduler_here");
        menu.setSkin("dhx_blue");
        menu.loadXML("dhxmenu.xml");
        //menu.setAutoShowMode(false);

        scheduler.attachEvent("onContextMenu", function (event_id, e){
            if ( event_id != null ) {
                menu.showContextMenu(e.clientX,e.clientY);
            } else {
            }
        });

If I use setAutoSHowMode, then I have to hold down the right mouse button to see the menu. If I don’t use setAuto, then the context menu will be shown anywhere.

How to make so, that the context menu shows only on event, but stays after I release right mb?

Hello,

Check the following sample:

[code]

<script src="../../codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="../../codebase/dhtmlxscheduler.css" type="text/css" media="screen" title="no title" charset="utf-8">

<link rel="stylesheet" type="text/css" href="../../../dhtmlxMenu/codebase/skins/dhtmlxmenu_dhx_skyblue.css">
<script src="../../../dhtmlXMenu/codebase/dhtmlxcommon.js"></script>
<script src="../../../dhtmlxMenu/codebase/dhtmlxmenu.js"></script>
html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }
 
 
[/code] Hope this helps.

Best regards,
Ilya

Sorry, I’m having trouble getting the example to work. No context zone? Maybe you can post zip?

My axe hack:

    menu = new dhtmlXMenuObject();
    menu.renderAsContextMenu();
    menu.addContextZone("scheduler_here");
    menu.setSkin("dhx_blue");

            scheduler.attachEvent("onContextMenu", function (event_id, e){
                if ( event_id != null ) {
                    menu.clearAll();
                    menu.loadXMLString('<menu><item id="seaded" text="Seaded"><item id="sms_logi" text="SMS Logi"/></item></menu>', null);
                    menu.showContextMenu(e.clientX,e.clientY);
                } else {
                    menu.clearAll();
                    menu.loadXMLString("<menu></menu>", null);
                    menu.showContextMenu(e.clientX,e.clientY);
                }
            });

I couldn’t use menu loadXML, something was out of sync (firebug showed get, but menu showed up after I hold down the rmb for longer time or clicked repeatedly) and the menu didn’t show up. loadXMLString works atm.

Hello,

Please check sample in the attachment.

Best regards,
Ilya
scheduler_menu_sample.zip (454 KB)