mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-15 23:48:15 +08:00
Add TakeFocus and SetActiveChild.
This allows developers to set child children component must be the currently active/focused one. This can be used to "control" where the focus is, without user interactions.
This commit is contained in:

committed by
Arthur Sonzogni

parent
114ab4ae2a
commit
81d79d311d
@@ -39,11 +39,18 @@ class Component {
|
||||
// We say an element has the focus if the chain of ActiveChild() from the
|
||||
// root component contains this object.
|
||||
virtual Component* ActiveChild();
|
||||
|
||||
// Whether this is the active child of its parent.
|
||||
bool Active();
|
||||
// Whether all the ancestors are active.
|
||||
bool Focused();
|
||||
|
||||
// Make the |child| to be the "active" one.
|
||||
virtual void SetActiveChild(Component* child);
|
||||
|
||||
// Configure all the ancestors to give focus to this component.
|
||||
void TakeFocus();
|
||||
|
||||
private:
|
||||
Component* parent_ = nullptr;
|
||||
void Detach();
|
||||
|
@@ -18,6 +18,7 @@ class Container : public Component {
|
||||
bool OnEvent(Event event) override;
|
||||
Element Render() override;
|
||||
Component* ActiveChild() override;
|
||||
virtual void SetActiveChild(Component*) override;
|
||||
|
||||
protected:
|
||||
// Handlers
|
||||
|
Reference in New Issue
Block a user