How to identify ui component classes that other ui components can be children of

6 ビュー (過去 30 日間)
I am trying to identify ui components like uipanels, uigridlayouts, uitabs, etc., that may contain other ui components as children.
Right now I'm just testing if the class name contains "matlab.ui.container" or is a figure:
contains(class(o),'matlab.ui.container') || isa(o,'matlab.ui.Figure') ...
Is there a better way?
  1 件のコメント
J. Alex Lee
J. Alex Lee 2021 年 4 月 22 日
i think my need for this was largely obsoleted by the R2020b+ feature of CompontentContainer, which manages for you the constructor/setup syntax and input parsing.

サインインしてコメントする。

採用された回答

Monika Phadnis
Monika Phadnis 2020 年 5 月 12 日
You can also use the 'Children' property of UI components.
This property contains list of child component objects if any, it is empty otherwise.
For example, you can refer to this documentation for 'uifigure' properties and 'uipanel' properties :
You can check if this property is empty or has some components under it.
  1 件のコメント
J. Alex Lee
J. Alex Lee 2020 年 5 月 12 日
Looks like this could be it, thanks! I didn't realize that components that can't have Children don't have that property, nor that querying Children would return an empty graphics handle if empty, rather than just empty...these 2 together should be enough to make a reasonably robust check!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by