contextmenu

Hello,



I want to have a contextmenu for all my screen but i don’t know how make it.



My HTML sources are like that :





    



    


… BODY HTML …







And my init script is :



var menuCtxt = new dhtmlXMenuObject();

menuCtxt.renderAsContextMenu();

menuCtxt.attachEvent(“onBeforeContextMenu”, function(zoneId){alert(zoneId);});

menuCtxt.addContextZone(“ContextArea”);



and i try too the HTML sources :





    


… BODY HTML …







But in these two cases, it doesn’t work. Why?



Regards


Hello,


we have added abiltity to attach context menu to the document body.


Please have a look at the attached sample. This sample contains modified dhtmlxmenu.js, so please use this file in your application


body_init.zip (55.1 KB)

Thanks,

But i use a full compressed version of DHTMLX.js how can i use it and your version of dhtmlxmenu.js ???

Regards


You can either generate the new dhtmlx.js (in this case it is necessary replace dhtmlxMenu/codebase/dhtmlxmenu.js with the new one) or include this file after dhtmlx.js in a page.

Thanks

But how can i generate the new dhtmlx.js ?


it can be done using libCompliler. It is included in the Suite package.

Thanks for all.

i want use a dynamic context menu in my page. After attach my contet menu to my body, i use the onBeforeContextMenu Event to load the content of my menu. In this event how i can know on which object is the target of my right click ??

Regards


You can make the following modification in the dhtmlxmenu.js to get target from onBeforeContextMenu event:


please locate this line in the dhtmlxmenu.js


if (this.callEvent(“onBeforeContextMenu”, [cZone.id])) {


and replace it with


if (this.callEvent(“onBeforeContextMenu”, [cZone.id,e])) {


(just add e into the array)


After that you can apply the following method:


menu.attachEvent(“onBeforeContextMenu”,function(zoneId,ev){
var target_element = ev.srcElement||ev.target;
/your code here/
return true
})



Thanks