ftxui::ComponentBase
#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
| Symbol | Description |
|---|---|
ComponentBase | |
~ComponentBase | |
operator= | |
Parent | Return the parent ComponentBase, or nul if any. |
ChildAt | Access the child at index i. |
ChildCount | Returns the number of children. |
Index | Return index of the component in its parent. -1 if no parent. |
Add | Add a child. |
Detach | Detach this child from its 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. |
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 | Called in response to an event. |
OnAnimation | Called in response to an animation event. |
ActiveChild | Return the currently Active child. |
Focusable | Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard. |
Active | Returns if the element if the currently active child of its parent. |
Focused | 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 | Make the child to be the "active" one. |
TakeFocus | Configure all the ancestors to give focus to this component. |
Public Member Functions
ComponentBase
ComponentBase(Components children);Examples: component/collapsible, component/scrollbar, component/window
~ComponentBase
virtual ~ComponentBase();ComponentBase
ComponentBase();Examples: component/collapsible, component/scrollbar, component/window
ComponentBase
ComponentBase(const ComponentBase &);Examples: component/collapsible, component/scrollbar, component/window
ComponentBase
ComponentBase(ComponentBase &&);Examples: component/collapsible, component/scrollbar, component/window
operator=
ComponentBase & operator=(const ComponentBase &);operator=
ComponentBase & operator=(ComponentBase &&);Parent
ComponentBase * Parent() const;Return the parent ComponentBase, or nul if any.
ChildAt
Access the child at index i.
ChildCount
size_t ChildCount() const;Returns the number of children.
Index
int Index() const;Return index of the component in its parent. -1 if no parent.
Add
Add a child.
Parameters:
child: The child to be attached.
Detach
void Detach();Detach this child from its parent.
DetachAllChildren
void 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
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
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
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
virtual Component ActiveChild();Return the currently Active child.
Returns: the currently Active child.
Focusable
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
bool Active() const;Returns if the element if the currently active child of its parent.
Focused
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
virtual void SetActiveChild(ComponentBase * child);Make the child to be the "active" one.
Parameters:
child: the child to become active.
SetActiveChild
void SetActiveChild(Component child);Make the child to be the "active" one.
Parameters:
child: the child to become active.
TakeFocus
void TakeFocus();Configure all the ancestors to give focus to this component.