A container used to display the contents of a popup menu. When a menupopup is open, it floats above the window and may extend outside the window border. There are several ways in which a menupopup may be used:
menu
, menulist
, toolbarbutton
, or a button
with the type attribute set to "menu" to create a popup that will open when the menu or button is pressed.popup
attribute. When the element is clicked with the left mouse button, the menupopup will be displayed.context
attribute. When a context menu is opened, the menupopup will be displayed. A context menu may be opened by right-clicking the element, or by pressing the menu key on the keyboard.More information is available in the XUL tutorial and Popup Guide.
The following example shows how a menupopup may be attached to a menulist
.
<menulist> <menupopup> <menuitem label="Mozilla" value="http://mozilla.org"/> <menuitem label="Slashdot" value="http://slashdot.org"/> <menuitem label="Sourceforge" value="http://sf.net"/> <menuitem label="Freshmeat" value="http://freshmeat.net"/> </menupopup> </menulist>
The following example shows how a menupopup can be used as a context menu for an element. When the label is right-clicked, the menu will be displayed.
<menupopup id="clipmenu"> <menuitem label="Cut"/> <menuitem label="Copy"/> <menuitem label="Paste"/> </menupopup> <label value="Right click for popup" context="clipmenu"/>
ignorekeys
true
, keyboard navigation between items in the popup is disabled.onpopuphiding
onpopupshowing
false
from this event handler prevents the popup from appearing.onpopupshown
onload
event is sent to a window when it is opened.position
position
attribute determines where the popup appears relative to the element the user clicked to invoke the popup. This allows you to place the popup on one side of a button. Note that a context menu will never respect this attribute, always appearing relative to the mouse cursor.topleft
, topright
, bottomleft
, bottomright
, leftcenter
, rightcenter
, topcenter
or bottomcenter
. The popup value (ie, the second word) can be one of topleft
, topright
, bottomleft
or bottomright
.after_start
, after_end
, before_start
, before_end
, end_after
, end_before
, start_after
, start_before
, overlap
, at_pointer
or after_pointer
.
accessibleType
anchorNode
nsIDOMElement
popupBoxObject
nsIPopupBoxObject
nsIPopupBoxObject
that implements the popup. You wouldn't normally need to use this property as all of its functions are available via the popup itself.state
closed
: The popup is closed and not visible.open
: The popup is open and visible on screen.showing
: A request has been made to open the popup, but it has not yet been shown. This state will occur during the popupshowing event.hiding
: The popup is about to be hidden. This state will occur during the popuphiding event.triggerNode
nsIDOMNode
null
if the popup isn't open.hidePopup()
moveTo( x, y )
openPopup( anchor , position , x , y , isContextMenu, attributesOverride, triggerEvent )
Opens the popup relative to a specified node at a specific location.
null
as the anchor node. The direction in which the popup is oriented depends on the direction of the anchor.before_start
, before_end
, after_start
, after_end
, start_before
, start_after
, end_before
, end_after
, overlap
, and after_pointer
. Check Positioning of the Popup Guide for a precise description of the effect of the different values.x
and y
arguments may be used to offset the popup from its anchored position by some number, measured in CSS pixels. An unanchored popup appears at the position specified by x and y, relative to the viewport of the document containing the popup node. In this case, the position
and attributesOverride
arguments are ignored.isContextMenu
argument should be true
for context menus and false
for all other types of popups. It affects menu item highlighting; that is, while a context menu is open, menus opened earlier do not highlight or execute their items.attributesOverride
argument is true
, the position attribute on the popup node overrides the position
value argument. If attributesOverride
is false
, the attribute is only used if the position
argument is empty.openPopupAtScreen( x, y, isContextMenu )
showPopup( element, x, y, popupType, anchor, align )
Deprecated since Gecko 1.9-1
, the popup will be positioned relative to the element specified as the first argument. This is what you might do to show a popup below a button, for example. In this latter case, the anchor and align arguments may be used to further control where the popup appears relative to the element. The anchor argument corresponds to the popupanchor
attribute on the element. The align argument corresponds to the popupalign
attribute on the element. The anchor and align arguments are ignored if either x or y are not -1
.boxObject
.screenX and boxObject
.screenY properties of the element, and use those as the x and y arguments offset by the desired values.popup
, context
, or tooltip
. Each type of popup is intended to be displayed only temporarily; they are not expected to be displayed permanently.sizeTo( width, height )
menu
, menubar
, menuitem
, menulist
, menuseparator
nsIAccessibleProvider
, nsIDOMXULPopupElement