AnchoredPopup
AnchoredPopup in UIToolbox shows an element under an anchor, as a drop-down. SearchDropdown, ComboBox, AutoCompleteField, DatePicker and the PropertyGrid color swatch use it.


// adds the tb-popup class to content
var popup = new AnchoredPopup(content);
popup.Closed += () => Debug.Log("closed");
button.clicked += () =>
{
if (popup.IsOpen) popup.Close();
else popup.Open(field, keepOpenOn: button);
};
| Member | Description |
|---|---|
Open(anchor, keepOpenOn, matchWidth) |
Shows the content under the anchor, at its left edge. matchWidth makes the content as wide as the anchor. The content follows the layout of the anchor while it shows, so a popup opened on a panel that shows in the same frame goes under the anchor at its first layout. Returns false when the popup is open or the anchor has no panel. |
OpenBeside(anchor, side, keepOpenOn, gap) |
Shows the content on one side of the anchor (TooltipPlacement.Above, Below, Left or Right), centered along it, gap pixels away (2 by default). It goes to the opposite side when side has no room, and it stays inside its host. It is placed again when the content changes size or the anchor changes its layout while it shows. Returns false when the popup is open or the anchor has no panel. |
OpenAt(anchor, worldPosition, keepOpenOn, owner) |
Shows the content at a panel position, such as the pointer. owner is a popup that this one belongs to, such as the menu of a submenu: a click in the owner does not close this popup. |
Close(), IsOpen, Closed |
Hides the content. Closed is sent after Close() and after a click outside. |
Content |
The element that shows. |
CloseOnEscape |
True to close the popup on Escape or the Cancel button of a gamepad, and give the focus back to the anchor that opened it. Off by default. |
A popup above a button, such as a volume slider, that closes on Escape and gives the focus back to the button:
var popup = new AnchoredPopup(panel) { CloseOnEscape = true };
sound.clicked += () =>
{
if (popup.IsOpen) popup.Close();
else popup.OpenBeside(sound, TooltipPlacement.Above,
keepOpenOn: sound);
};
- The content goes in the nearest
Workspace, so it gets the workspace theme, or in the top element of its document. It stays inside its host. - A pointer down outside the content and outside
keepOpenOncloses it. Give the toggle button askeepOpenOn, so that its click toggles instead of closing and opening again. - A window that gets focus comes in front of the other windows only. An open popup, menu or notification stays in front of it.
Styling
| Class | Element |
|---|---|
tb-popup |
The content of every AnchoredPopup: the search list, the calendar and the color popup. Absolute position, surface, border and small radius. It is in the workspace or the top element of the document, not in the control. |
tb-style-scope |
Not on the popup: on an ancestor of the control. The open popup takes the classes of the nearest one. See Style families and style scopes. |