XUL Programmer's Reference Manual

<popup>

Attributes Common Children
id titledbutton
oncreate window
ondestroy menu
oncommand  

The XUL language provides a way for developers to declare that a XUL subtree is popup content, meaning that the content is displayed in its own window when a certain event occurs (e.g., a right mouse click to bring up a context menu, or a left click to bring up a popup color picker on a toolbar). There are two kinds of popup content: menus and windows. Popup menus use the native menus on each platform and are described using menu and menuitem elements. Popup windows can contain arbitrary XUL, and are full-fledged XUL windows, declared using the window tag (See Windows and Dialogs for details). 

Popup content is placed inside a popup tag, which prevents it from being displayed in the main document. The popup tag always has an identifier attached to it (using the id attribute) that is used when attaching the popup content to a UI element. 

 
<popup id="replyMenu">
 <menu>
   <menuitem name="Reply to Sender">
   <menuitem name="Reply to All">
 </menu>
</popup>
                                     
Popups are positioned on the anchoring element with that element's popupanchor and popupalign attributes. There are three different ways of automatically attaching a popup to content. All three methods involve setting attributes on the content node that should have the popup content attached to it. The attributes are popup, context, and tooltip. The value of one of these attributes is the id of the popup element that should be used to build the popup content. 
 
<titledbutton value="Reply" popup="replyMenu"/>
     
The popup attribute is used to attach popup content that will be invoked on a left mouse down. The context attribute is used to attach popup content that will be invoked on a context menu event (with the cross-platform abstraction being taken care of for you). The tooltip attribute is used to attach popup content that will be invoked after a time-delay hover over the node that has the popup content attached.(Note that tooltips may only be used with popup window content and never with popup menu content.)
 
 

 

oncreate
Description
oncreate is an optional event listener attribute. 
Syntax
<popup id="string" oncreate="event handler code" />


Example

<popup id="main-context" type="menu" oncreate="checkForExtraVerbs()" />


Notes

The create event is fired when a popup is displayed in the UI -- for example when the user right clicks in a content window and a context menu pops up.

 

 

ondestroy
Description
ondestroy is an optional event listener attribute for handling the event fired when a popup is "destroyed", or removed from display.
Syntax
<popup id="string" ondestroy="event handler code" />


Example

<popup id="main-context" type="menu" ondestroy="cleanupWindow()" />


Notes

The destroy event is fired when an item is selected from a popup and the popup disappears from view.

 

 

Last updated: 4/13/00 Ian Oeschger