Context Menus

Components: popup and menupopup.

You can assign the ID of a popup or menupopup component to the context property of any XUL component, such that the popup or menupopup component is opened when a user right-clicks on it.

As depicted below, a context menu is enabled by simply assigning the ID to the context property. Of course, you can assign the same ID to multiple components.

<label value="Right Click Me!" context="editPopup"/>
<separator bar="true"/><label value="Right Click Me!" onRightClick="alert(self.value)"/>
<menupopup id="editPopup">
<menuitem label="Undo"/>
<menuitem label="Redo"/>
<menu label="Sort">
        <menupopup>        
     <menuitem label="Sort by Name" autocheck="true"/>    
     <menuitem label="Sort by Date" autocheck="true"/>    
        </menupopup>        
</menu>
</menupopup>

Notice that menupopup is not visible until a user right-clicks on a component associated with its ID.

Trick: If you just want to disable browser's default context menu, you can specify non-existent ID to the context property.

The popup component is a more generic popup than menupopup. You can place any kind of components inside of popup. For example,

<label value="Right Click Me!" context="any"/>

<popup id="any" width="300px">
    <vbox>    
        It can be anything.        
        <toolbarbutton label="ZK" href="http://zk1.sourceforge.net"/>        
    </vbox>    
</popup>