MoveResize

Moving and Resizing a Popup

Menus and popups have methods which may be used to move and resize them.

Moving a Popup

Once a popup is open, it can be moved using the popup's moveTo method.

void moveTo(in long left, in long top);

The left argument is the horizontal screen position and the top argument is the vertical screen position. This method will change the left and top attributes to match the supplied arguments, so if these attributes are persisted the values will be restored when the window is displayed again.

For instance, the following example will move a popup to the upper left corner of the screen:

popup.moveTo(0, 0);

The position may be shifted so as not to cover user interface elements provided by the operating system, such as the menu bar or the task bar.

Resizing a Popup

The size of a popup is determined automatically based on the content inside the popup. For instance, the size of a menu will be large enough to fit all of the items within the menu. Sometimes, a menu will be larger than the available space on the screen; in this situation, the menu may be moved such that it will fit on screen. For instance, instead of appearing below the menu label, the menu popup might appear above the label. You can see this effect in a XUL application by moving a window near the bottom of the screen and clicking a menu or button that has a menu.

If a popup is still too large, it will be resized to fit on the screen. Arrows will appear on the ends of the menu to allow a user to scroll through the items.

A popup can be resized manually using the popup's sizeTo method.

void sizeTo(in long width, in long height);

Here is an example which resizes a popup to be 200 pixels wide and 300 pixels high:

popup.sizeTo(200, 300);