Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by learner on Nov 14, 2007 01:17
open dhtmlx forum
Context Menu

I was using Context Menu ,my html document structured as follows:

<document> (main html)
BtMenu=new dhtmlXContextMenuObject('120',0,"pup up menu");    
<div>
<frameset> (second html)
<frame1>
< Button onclick=" BtMenu.openAt(x,y);" > (three html)
<frame2>

Context Menu object can be created in top level document. when I click the Button, the Context Menu will pop up. But if I did not click on the Context Menu, the Context Menu will continue show there, Unless click on the main html. So I hope the Context Menu can shut down automatically£¬just like the ¡°http://dhtmlx.com¡± menu . How can I set a timer(e.g. 1 second) when Context Menu pop up , the mouse was moved out from the Context Menu or button , the Context Menu will auto close? Thanks!
Answer posted on Nov 14, 2007 01:59
The menu must close on any click outside it, in multiframe structure it may nto work as expected because it monitor only native window for events, it can be fixed by adding code similar to next

    document.body.onclick=function(){
        if (top.document.body.onclick) top.document.body.onclick();
    }

it will transfer click event from child iframes to top so any click in child iframe will be catched in top one and menu can correctly process it


There is no native support for "close on mouse out" behavior. Menu has two inner methods which fire on mouseout, mousein which can be modified to achieve desired functionality ( menu._onmouseoverZ and menu.__onmouseoutZ )