Skip to content
You are viewing documentation for v7.0.3. Switch to latest (main).

ftxui::ComponentBase ​

cpp
#include <ftxui/component/component_base.hpp>

It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ftxui::Event.

Examples: component/collapsible, component/scrollbar, component/window

Summary ​

SymbolDescription
ComponentBase
~ComponentBase
operator=
ParentReturn the parent ComponentBase, or nul if any.
ChildAtAccess the child at index i.
ChildCountReturns the number of children.
IndexReturn index of the component in its parent. -1 if no parent.
AddAdd a child.
DetachDetach this child from its parent.
DetachAllChildrenRemove all children.
RenderDraw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::ComponentBase. Please override OnRender() to modify the rendering.
OnRenderDraw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase. This function is means to be overridden.
OnEventCalled in response to an event.
OnAnimationCalled in response to an animation event.
ActiveChildReturn the currently Active child.
FocusableReturn true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard.
ActiveReturns if the element if the currently active child of its parent.
FocusedReturns if the elements if focused by the user. True when the ComponentBase is focused by the user. An element is Focused when it is with all its ancestors the ActiveChild() of their parents, and it Focusable().
SetActiveChildMake the child to be the "active" one.
TakeFocusConfigure all the ancestors to give focus to this component.

Public Member Functions ​

ComponentBase ​

Examples: component/collapsible, component/scrollbar, component/window

~ComponentBase ​

cpp
virtual ~ComponentBase();

ComponentBase ​

Examples: component/collapsible, component/scrollbar, component/window

ComponentBase ​

Examples: component/collapsible, component/scrollbar, component/window

ComponentBase ​

Examples: component/collapsible, component/scrollbar, component/window

operator= ​

cpp
ComponentBase & operator=(const ComponentBase &);

operator= ​

cpp
ComponentBase & operator=(ComponentBase &&);

Parent ​

cpp
ComponentBase * Parent() const;

Return the parent ComponentBase, or nul if any.

See also: Detach, Parent

ChildAt ​

cpp
Component & ChildAt(size_t i);

Access the child at index i.

ChildCount ​

cpp
size_t ChildCount() const;

Returns the number of children.

Index ​

cpp
int Index() const;

Return index of the component in its parent. -1 if no parent.

Add ​

cpp
void Add(Component children);

Add a child.

Parameters:

  • child: The child to be attached.

Detach ​

cpp
void Detach();

Detach this child from its parent.

See also: Detach, Parent

DetachAllChildren ​

Remove all children.

Render ​

Draw the component. Build a ftxui::Element to be drawn on the ftxui::Screen representing this ftxui::ComponentBase. Please override OnRender() to modify the rendering.

Examples: component/button, component/button_animated, component/button_in_frame, component/canvas_animated, component/checkbox_in_frame, component/collapsible, component/composition, component/flexbox_gallery, component/focus, component/gallery, component/homescreen, component/input (+61 more)

OnRender ​

cpp
virtual Element OnRender();

Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase. This function is means to be overridden.

OnEvent ​

cpp
virtual bool OnEvent(Event);

Called in response to an event.

Parameters:

  • event: The event.

Returns: True when the event has been handled. The default implementation called OnEvent on every child until one return true. If none returns true, return false.

OnAnimation ​

cpp
virtual void OnAnimation(animation::Params & params);

Called in response to an animation event.

Parameters:

  • params: the parameters of the animation The default implementation dispatch the event to every child.

ActiveChild ​

cpp
virtual Component ActiveChild();

Return the currently Active child.

Returns: the currently Active child.

Focusable ​

cpp
virtual bool Focusable() const;

Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard.

Active ​

cpp
bool Active() const;

Returns if the element if the currently active child of its parent.

Focused ​

cpp
bool Focused() const;

Returns if the elements if focused by the user. True when the ComponentBase is focused by the user. An element is Focused when it is with all its ancestors the ActiveChild() of their parents, and it Focusable().

SetActiveChild ​

cpp
virtual void SetActiveChild(ComponentBase * child);

Make the child to be the "active" one.

Parameters:

  • child: the child to become active.

SetActiveChild ​

cpp
void SetActiveChild(Component child);

Make the child to be the "active" one.

Parameters:

  • child: the child to become active.

TakeFocus ​

cpp
void TakeFocus();

Configure all the ancestors to give focus to this component.