Replies: 5 comments 9 replies
-
|
It used to be possible, but then I wasn't able to extend FTXUI because the API surface was too large and I had to break users often. So I removed this and the implementations are now fully hidden. Instead of inheritance, what about using composition? The Dropdown component is a Good example: Please let me know if you encounter any issues, and have suggestions how to improve FTXUI. |
Beta Was this translation helpful? Give feedback.
-
|
What exactly would composition mean? bool selected; // whether the component should display contents or as item
Element Render() override {
return selected ? container->Render() : asItem->Render();
}
bool OnEvent(Event e) override {
if (ANote::OnEvent(e)) return true;
if (!selected) return false;
if (container->OnEvent(e)) return true;
if (e == Event::Character('\n') && children_.size() > 0) {
setSelected(false);
((ANote*) children_[focused].get())->setSelected(true);
stack.push_back(children_[focused]);
return true;
} else return false;
}Sorry, this is my first time trying to make a basic app, and it's for a school project. |
Beta Was this translation helpful? Give feedback.
-
|
Oh, I just noticed I also cannot use CatchEvent, because it first tries to catch, then defer to the component, I need the opposite order. |
Beta Was this translation helpful? Give feedback.
-
|
BTW why is Edit: Because we don't have the reference to the original shared pointer anyway, but that could be improved by holding a const Component _this((ComponentBase *) this);
public:
operator Component() const { return _this; } |
Beta Was this translation helpful? Give feedback.
-
|
The parent requirement is putting me into a difficult situation. Because I have two ways to display my component, based on the way it's being displayed it has a different parent, but changing the parent is possible only through the Add method that cannot be changed. This means, that initially, all children are allright. This can be worked around by adding the element to the parent again and then manually removing it from the end again, but by directly accessing Edit: well, actually I cannot do even that because for whatever reason, cpp doesn't allow access of protected values of different entities, although the accessing class is extending the source of that protected value. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I haven't found a way with the current headers to create custom components by using existing ones and inheriting from them (other than
ComponentBase). This is a must-have feature for me - instead of wrapping around the components used, I can just modify the small part I am working with and use the rest (i.e.: dynamic content modification - currentContainercopies the vector, so adding/removing of elemenst won't propagate).I also struggle with a need to display the last component of a stack/list, so a wrapper there is also needed, but
RendererandCatchEvent(in combination) would add more than a single wrapping layer;Am I missing something, or has everyone used a wrapper to go around?
Beta Was this translation helpful? Give feedback.
All reactions