DropdownPopup
DropdownPopup
Section titled “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.
Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
DropdownPopup | Constructs a dropdown popup. | |
core::Size | measure virtual | Measures how much space this widget needs. |
bool | onEvent virtual | Handles an input event. |
bool | isFocusable virtual const inline | Returns whether this widget can receive keyboard focus. |
DropdownPopup
Section titled “DropdownPopup”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.
Parameters
Section titled “Parameters”-
optionsthe list of options to display -
initialSelectedthe initially selected option index -
onSelectcallback when an option is selected -
onClosecallback when the popup is closed -
parentDropdownweak reference to the parent dropdown widget
measure
Section titled “measure”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.
Parameters
Section titled “Parameters”-
availWMaximum available width (may be ignored by widget) -
availHMaximum available height (may be ignored by widget)
Returns
Section titled “Returns”The Size this widget wants, or needs at minimum
onEvent
Section titled “onEvent”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.
Parameters
Section titled “Parameters”eventThe input event
Returns
Section titled “Returns”True if this widget (or one of its listeners) handled the event
isFocusable
Section titled “isFocusable”virtual const inline
virtual inline bool isFocusable() constReturns whether this widget can receive keyboard focus.
Widgets like Button and Input return true; containers return false.
Returns
Section titled “Returns”True if this widget can be focused, false otherwise
Protected Methods
Section titled “Protected Methods”| Return | Name | Description |
|---|---|---|
void | drawContent virtual | Draws this widget’s content. |
drawContent
Section titled “drawContent”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.
Parameters
Section titled “Parameters”-
bufThe buffer to draw to -
innerThe inner rectangle (excluding border/padding)
Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
const std::vector< Dropdown::Option > & | options | |
int | hovered | |
int | initialSelected | |
int | scrollOffset | |
std::weak_ptr< Dropdown > | parentDropdown | |
std::function< void(int)> | onSelect | |
std::function< void()> | onClose |
options
Section titled “options”const std::vector< Dropdown::Option > & optionshovered
Section titled “hovered”int hoveredinitialSelected
Section titled “initialSelected”int initialSelectedscrollOffset
Section titled “scrollOffset”int scrollOffset = 0parentDropdown
Section titled “parentDropdown”std::weak_ptr< Dropdown > parentDropdownonSelect
Section titled “onSelect”std::function< void(int)> onSelectonClose
Section titled “onClose”std::function< void()> onClose