FTXUI  0.11.1
C++ functional terminal UI.
ComponentBase Class Reference

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

Inherited by CatchEventBase, ContainerBase, MenuBase, and SliderBase< T >.

Public Member Functions

virtual ~ComponentBase ()
 
ComponentBaseParent () const
 Return the parent ComponentBase, or nul if any. More...
 
ComponentChildAt (size_t i)
 Access the child at index i. More...
 
size_t ChildCount () const
 Returns the number of children. More...
 
void Add (Component children)
 Add a child. @param child The child to be attached. More...
 
void Detach ()
 Detach this child from its parent. More...
 
void DetachAllChildren ()
 Remove all children. More...
 
virtual Element Render ()
 Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase. More...
 
virtual bool OnEvent (Event)
 Called in response to an event. More...
 
virtual Component ActiveChild ()
 Return the currently Active child. More...
 
virtual bool Focusable () const
 Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard. More...
 
bool Active () const
 Returns if the element if the currently active child of its parent. More...
 
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. More...
 
virtual void SetActiveChild (ComponentBase *child)
 Make the |child| to be the "active" one. More...
 
void SetActiveChild (Component child)
 Make the |child| to be the "active" one. More...
 
void TakeFocus ()
 Configure all the ancestors to give focus to this component. More...
 

Protected Member Functions

CapturedMouse CaptureMouse (const Event &event)
 Take the CapturedMouse if available. There is only one component of them. It represents a component taking priority over others. More...
 

Protected Attributes

Components children_
 

Detailed Description

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

Definition at line 23 of file component_base.hpp.

Constructor & Destructor Documentation

◆ ~ComponentBase()

~ComponentBase ( )
virtual

Definition at line 21 of file component.cpp.

Member Function Documentation

◆ Parent()

ComponentBase * Parent ( ) const

Return the parent ComponentBase, or nul if any.

See also
Detach
Parent

Definition at line 29 of file component.cpp.

◆ ChildAt()

Component & ChildAt ( size_t  i)

Access the child at index i.

Definition at line 35 of file component.cpp.

◆ ChildCount()

size_t ChildCount ( ) const

Returns the number of children.

Definition at line 42 of file component.cpp.

◆ Add()

void Add ( Component  children)

Add a child. @param child The child to be attached.

Definition at line 49 of file component.cpp.

◆ Detach()

void Detach ( )

Detach this child from its parent.

See also
Detach
Parent

Definition at line 59 of file component.cpp.

◆ DetachAllChildren()

void DetachAllChildren ( )

Remove all children.

Definition at line 73 of file component.cpp.

◆ Render()

Element Render ( )
virtual

Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase.

Definition at line 82 of file component.cpp.

◆ OnEvent()

bool OnEvent ( Event  event)
virtual

Called in response to an event.

Parameters
eventThe 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.

Definition at line 95 of file component.cpp.

◆ ActiveChild()

Component ActiveChild ( )
virtual

Return the currently Active child.

Returns
the currently Active child.

Definition at line 106 of file component.cpp.

◆ Focusable()

bool Focusable ( ) const
virtual

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

Definition at line 114 of file component.cpp.

◆ Active()

bool Active ( ) const

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

Definition at line 124 of file component.cpp.

◆ 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.

Definition at line 132 of file component.cpp.

◆ SetActiveChild() [1/2]

void SetActiveChild ( ComponentBase child)
virtual

Make the |child| to be the "active" one.

Parameters
childthe child to become active.

Definition at line 143 of file component.cpp.

◆ SetActiveChild() [2/2]

void SetActiveChild ( Component  child)

Make the |child| to be the "active" one.

Parameters
childthe child to become active.

Definition at line 148 of file component.cpp.

◆ TakeFocus()

void TakeFocus ( )

Configure all the ancestors to give focus to this component.

Definition at line 154 of file component.cpp.

◆ CaptureMouse()

CapturedMouse CaptureMouse ( const Event event)
protected

Take the CapturedMouse if available. There is only one component of them. It represents a component taking priority over others.

Parameters
event

Definition at line 166 of file component.cpp.

Field Documentation

◆ children_

Components children_
protected

Definition at line 74 of file component_base.hpp.


The documentation for this class was generated from the following files: