AnchoredPopup in UIToolbox shows an element under an anchor, as a drop-down. SearchDropdown, ComboBox, AutoCompleteField, DatePicker and the PropertyGrid color swatch use it.
var popup = new AnchoredPopup(content); // adds the tb-popup class to 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. 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. |
- 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
keepOpenOn closes it. Give the toggle button as keepOpenOn, 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. |