2026-05-28 6:14 AM
I have a scroll list lightSoundSelectorScroll made by several items from the container lightSoundItem.
In the view I call lightSoundSelectorScroll.setVisible(false); or lightSoundSelectorScroll.setVisible(true); but, when calling this->isVisible() inside void lightSoundItem::handleTickEvent() I always have true even if I called lightSoundSelectorScroll.setVisible(false); before
Why is that?
Solved! Go to Solution.
2026-05-28 6:58 AM
Hi @JohanAstrup
that makes sense.
I've implemented the function
bool optionsItem::isEffectivelyVisible() const
{
const Drawable* node = this;
while (node != nullptr)
{
if (!node->isVisible()) return false;
node = node->getParent();
}
return true;
}to my custom container item, so I can check it in the optionsItem::handleTickEvent()
Not the cleaner solution, as it's polling instead of event-driven, but it works.
2026-05-28 6:34 AM
Hello @nico23.
The isVisible() function only checks whether the isVisible property is set on the given widget. It does not check whether the widget is actually shown on the screen. It will e.g. also return true if the alpha value is set to 0, while the isVisible property is still true.
In your case, you toggle the visibility on the parent but check the visibility on the child. However, the child will still have isVisible set to true.
If you want to continue with this approach, you could e.g. give the child a pointer to its parent. Then you can check whether the parent is visible.
Let me know if that makes sense.
Best regards,
Johan
2026-05-28 6:58 AM
Hi @JohanAstrup
that makes sense.
I've implemented the function
bool optionsItem::isEffectivelyVisible() const
{
const Drawable* node = this;
while (node != nullptr)
{
if (!node->isVisible()) return false;
node = node->getParent();
}
return true;
}to my custom container item, so I can check it in the optionsItem::handleTickEvent()
Not the cleaner solution, as it's polling instead of event-driven, but it works.
2026-05-29 1:50 AM
I thought of another option.
An even simpler approach could be to override the setVisible function in the lightSoundSelectorScroll container and pass the call on to the children as well. That way, the visible state of the children will always match the state of the parent, unless you modify the children directly.
At least, this means you would not need to get a pointer to the parent.
Best regards,
Johan
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.