Skip to content

Popup

Anchored floating popup widget that positions itself relative to target widgets or screen coordinates.

Overview

Popup represents a lightweight floating container anchored to a specific target widget or screen coordinate.

Key features: - Anchor-based relative positioning (TOP, BOTTOM, LEFT, RIGHT). - Boundary constraint checks against parent host bounds. - Optional dismissal when clicking outside the popup boundaries (closeOnOutsideClick). - State listeners for open and close events (onOpenChanged).

Opening Anchored Popup

Popup popup = new Popup(button, menuContent);
popup.open();
  • OverlayLayer: Full-screen overlay root managing modal backdrops, dialogs, popups, and layer-based hit testing.
  • Tooltip: Hover-activated floating information bubble displaying helper text, rich layout, and delay timers.

API

Constructs an empty Popup.

Popup(Widget, Widget)

Constructs a Popup bound to an anchor widget and displaying content.

Parameter Type Description
anchor Widget Anchor widget to position relative to.
content Widget Content widget hosted inside.

Popup::anchor()

Returns the anchor widget this popup is positioned relative to.

Returns Widget: The target anchor widget..

Popup::anchor(Widget)

Sets the anchor widget this popup is positioned relative to.

Parameter Type Description
anchor Widget Anchor widget to position relative to.

Returns Popup: This widget instance for chaining..

Popup::arrangeInHost(RectView)

Arranges the popup relative to its anchor within host bounds.

Parameter Type Description
bounds RectView Available host rectangular boundary.

Popup::close()

Closes the popup.

Returns Popup: This widget instance for chaining..

Popup::closeOnOutsideClick()

Returns true if outside pointer clicks automatically dismiss the popup.

Returns boolean: True if closing on outside click is enabled..

Popup::closeOnOutsideClick(boolean)

Sets whether outside clicks automatically close the popup.

Parameter Type Description
closeOnOutsideClick boolean Whether clicking outside automatically dismisses the widget.

Returns Popup: This widget instance for chaining..

Popup::content()

Returns the content widget hosted inside this popup.

Returns Widget: The hosted content widget..

Popup::content(Widget)

Sets the content widget displayed inside this popup.

Parameter Type Description
content Widget Content widget hosted inside.

Returns Popup: This widget instance for chaining..

Popup::offset(float, float)

Sets additional displacement offsets from the computed placement in UI pixels.

Parameter Type Description
x float Horizontal X coordinate.
y float Vertical Y coordinate.

Returns Popup: This widget instance for chaining..

Popup::onOpenChanged(Runnable)

Registers a listener invoked when the open state changes.

Parameter Type Description
onOpenChanged Runnable Callback invoked when popup open state changes.

Returns Popup: This widget instance for chaining..

Popup::open()

Opens the popup.

Returns Popup: This widget instance for chaining..

Popup::open(boolean)

Sets the open state of the popup.

Parameter Type Description
open boolean Target open state flag.

Returns Popup: This widget instance for chaining..

Popup::opened()

Returns true if this popup is currently open.

Returns boolean: True if currently open..

Popup::padding(EdgeInsets)

Sets the interior padding around popup content.

Parameter Type Description
padding EdgeInsets Internal content padding.

Returns Popup: This widget instance for chaining..

Popup::placement()

Returns the preferred anchor placement edge.

Returns Placement: The active placement position..

Popup::placement(Placement)

Sets the preferred anchor placement edge.

Parameter Type Description
placement Placement Popup placement relative to the anchor widget.

Returns Popup: This widget instance for chaining..

Popup::toggle()

Toggles between open and closed states.

Returns Popup: This widget instance for chaining..