diff --git a/Source/ThirdParty/TurboBadger/tb_widgets.cpp b/Source/ThirdParty/TurboBadger/tb_widgets.cpp index fb183d8283..bda1931d8d 100755 --- a/Source/ThirdParty/TurboBadger/tb_widgets.cpp +++ b/Source/ThirdParty/TurboBadger/tb_widgets.cpp @@ -814,11 +814,19 @@ bool TBWidget::IsEventDestinationFor(TBWidget *other_widget) const return false; } -TBWidget *TBWidget::GetParentRoot() +TBWidget *TBWidget::GetParentRoot(bool view_root) { TBWidget *tmp = this; + while (tmp->m_parent) + { + if (view_root && !tmp->m_parent->m_parent) + { + return tmp; + } + tmp = tmp->m_parent; + } return tmp; } diff --git a/Source/ThirdParty/TurboBadger/tb_widgets.h b/Source/ThirdParty/TurboBadger/tb_widgets.h index 615ceed0d8..2d0905ce29 100755 --- a/Source/ThirdParty/TurboBadger/tb_widgets.h +++ b/Source/ThirdParty/TurboBadger/tb_widgets.h @@ -752,8 +752,9 @@ class TBWidget : public TBTypedObject, public TBLinkOf for widgets having multiple children by default, to specify which one that should get the children. */ virtual TBWidget *GetContentRoot() { return this; } - /** Get this widget or a parent widget that is the absolute root parent. */ - TBWidget *GetParentRoot(); + /** Get this widget or a parent widget that is the absolute root parent + if view_root is true, will return the widget for the UIView attached to root widget */ + TBWidget *GetParentRoot(bool view_root = true); /** Get the closest parent widget that is a TBWindow or nullptr if there is none. If this widget is a window itself, this will be returned. */