C4 Engine
C4 Engine API Documentation

RootWidget::FindWidget

Defined in:  C4Widgets.h
Finds a widget with a particular key.
Prototype

Widget *FindWidget(const char *key) const;

Parameters
key The key value of the widget to find.
Description
The FindWidget function returns a pointer to the first widget in the subtree having a key matching the key parameter. If no such widget exists, or the key parameter is the empty string, then the return value is nullptr.

Multiple widgets can have the same key value, and the FindWidget function returns a pointer to the first widget with the specified key, in the order in which widgets were preprocessed. To iterate over all widgets having the same key value, call the Widget::GetNextWidgetWithSameKey function repeatedly until it returns nullptr.

The FindWidget function can only be called after the root widget has been preprocessed because the internal structures used to search for widgets are established during the preprocessing step. Thus, it is common for calls to FindWidget to appear in the PreprocessWidget function implementation in subclasses of the Window, Board, or Page classes.
See Also

Widget::GetNextWidgetWithSameKey

Window

Board