3 Replies Latest reply on Apr 17, 2009 7:06 AM by ilya_shaikovsky

    attach contextmenu to panel via componentControl

    captainvoid

      Hi,
      I'm having problems attaching a contextmenu to a <rich:panel> via <rich:componentControl>. The menu does not show on right click. I think the reason is that there is no "oncontextmenu" event available in the panel.
      Of course, I could just make the contextmenu a child component of my panel, and with attched="true" it would be attached automatically to my panel.
      BUT: If I do it like this then the default right click menu is disabled for the whole page. However, using componentControl and setting disableDefault="true" which stops the event bubbling, the default browser context menu only gets disabled for the region where my contextmenu is used (this is what I want).
      I think the real problem here is that disableDefaultMenu="true" in rich:contextMenu disables the default context menu for the whole page. May be this should be considered as a bug?

      my code (context menu does not show up on right mouse click):

      <rich:contextMenu id="myCtxtMenu"
       disableDefaultMenu="false"
       attached="false" >
       ...
       ...
      </rich:contextMenu>
      
      <rich:panel id="myPanel">
       ...
       ...
       <rich:componentControl
       event="oncontextmenu"
       name="showMyCtxtMenu"
       for="myCtxtMenu"
       operation="show"
       disableDefault="true" />
      </rich:panel>
      


      this works, but contextmenu will be disabled for the whole page:
      <rich:panel id="myPanel">
       ...
       ...
       <rich:contextMenu id="myCtxtMenu"
       disableDefaultMenu="true"
       attached="true" >
       ...
       ...
       </rich:contextMenu>
      </rich:panel>
      


      Anybody an idea?