"Unrecognized method, property, or field 'Type' for class 'matlab.ui​.control.W​ebComponen​t'."

15 次查看(过去 30 天)
In App Designer (MATLAB R2024a, Windows 10 Pro, 64-bit) I have a tab (app.tabFiles) that has a few ui components on it. When I query the Type property on all of them at once, I get the following error:
tf = strcmp({app.tabFiles.Children.Type}, 'uistatebutton') ; % This works fine with 7 other tabs, panels, etc
"Unrecognized method, property, or field 'Type' for class 'matlab.ui.control.WebComponent'."
However, if I query the Type of the components individually, each happily returns its Type. Huh?
I should mention, there are 13 components visible on the tab and 13 listed in the Component Browser. However, the tab has 14 Children - the extra child is the label (set to empty string) on a uieditfield component - but all respond as expected to the individual Type request.
Any idea what would cause that exception to be thrown? And how to avoid it?

采纳的回答

Fangjun Jiang
Fangjun Jiang 2024-4-14
编辑:Fangjun Jiang 2024-4-14
I think app.tabFiles.Children is an array of handles. Try tf = strcmp(get(app.tabFiles.Children,'Type'), 'uistatebutton')
  2 个评论
Dave Watson
Dave Watson 2024-4-16
Yes, thank you, that works. However, it should be equivalent to what I did and my approach works on other UI components with Children, with that one exception. Mysteries of MATLAB! Thanks, again.
Fangjun Jiang
Fangjun Jiang 2024-4-16
close all;plot(1:3);
obj=findobj(0)
obj =
4x1 graphics array: Root Figure (1) Axes Line
obj(1).Type
ans = 'root'
get(obj,'Type')
ans = 4x1 cell array
{'root' } {'figure'} {'axes' } {'line' }
obj.Type
Unrecognized method, property, or field 'Type' for class 'matlab.graphics.Graphics'.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Install Products 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by