mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-28 16:29:34 +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
@@ -47,6 +47,15 @@ Component* Container::ActiveChild() {
|
||||
return children_[selected % children_.size()];
|
||||
}
|
||||
|
||||
void Container::SetActiveChild(Component* child) {
|
||||
for(size_t i = 0; i < children_.size(); ++i) {
|
||||
if (children_[i] == child) {
|
||||
(selector_ ? *selector_ : selected_) = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Container::VerticalEvent(Event event) {
|
||||
int old_selected = selected_;
|
||||
if (event == Event::ArrowUp || event == Event::Character('k'))
|
||||
|
Reference in New Issue
Block a user