Skip to content

DropdownPopup

#include <Dropdown.hpp>

Inherits: Widget

The floating list that appears when a Dropdown is opened. Managed by OverlayManager, not added to the widget tree directly.

ReturnNameDescription
DropdownPopupConstructs a dropdown popup.
core::Sizemeasure virtualMeasures how much space this widget needs.
boolonEvent virtualHandles an input event.
boolisFocusable virtual const inlineReturns whether this widget can receive keyboard focus.

DropdownPopup(const std::vector< Dropdown::Option > & options, int initialSelected, std::function< void(int)> onSelect, std::function< void()> onClose, std::weak_ptr< Dropdown > parentDropdown)

Constructs a dropdown popup.

  • options the list of options to display

  • initialSelected the initially selected option index

  • onSelect callback when an option is selected

  • onClose callback when the popup is closed

  • parentDropdown weak reference to the parent dropdown widget


virtual

virtual core::Size measure(int availW, int availH)

Measures how much space this widget needs.

Called during the measurement pass to determine widget size requirements. Should return the preferred size based on available space.

  • availW Maximum available width (may be ignored by widget)

  • availH Maximum available height (may be ignored by widget)

The Size this widget wants, or needs at minimum


virtual

virtual bool onEvent(const core::events::Event & event)

Handles an input event.

Called by the framework to deliver an event to this widget. The default implementation runs any listeners registered via addEventListener(), then returns false. Subclasses (Button, Input, etc.) override this to add built-in behavior, and should call Widget::onEvent(event) first to give user listeners a chance to handle the event before the widget’s own logic.

Return true if the event was handled, false to let it bubble to the parent widget.

  • event The input event

True if this widget (or one of its listeners) handled the event


virtual const inline

virtual inline bool isFocusable() const

Returns whether this widget can receive keyboard focus.

Widgets like Button and Input return true; containers return false.

True if this widget can be focused, false otherwise

ReturnNameDescription
voiddrawContent virtualDraws this widget’s content.

virtual

virtual void drawContent(backend::Buffer & buf, core::Rect inner)

Draws this widget’s content.

Called by render() after background and borders are drawn. This is where you should draw your widget’s actual content. The inner rectangle accounts for borders and padding.

  • buf The buffer to draw to

  • inner The inner rectangle (excluding border/padding)

ReturnNameDescription
const std::vector< Dropdown::Option > &options
inthovered
intinitialSelected
intscrollOffset
std::weak_ptr< Dropdown >parentDropdown
std::function< void(int)>onSelect
std::function< void()>onClose

const std::vector< Dropdown::Option > & options

int hovered

int initialSelected

int scrollOffset = 0

std::weak_ptr< Dropdown > parentDropdown

std::function< void(int)> onSelect

std::function< void()> onClose