Default properties don't affect graphics, that are created with an empty parent

조회 수: 2 (최근 30일)
I regularly use graphics that are intentionally created unparented. Since I want my apps to work on all platforms, I have the need to adapt font sizes. I tried to make use the default properties functionality to non-invasively make font sizes in my apps adapt to the platform the app is running on.
Unfortunately I encounter this unpleasant behavior, where the default property values seem to have no effect on graphics, if they are created with an empty parent.
set(groot, 'DefaultUicontrolFontSize', 14)
c = uicontrol('Parent',gcf);
c.FontSize % returns 14
c = uicontrol('Parent',[]);
c.FontSize % returns 10
Maybe there is a way for this to be the intended behavior, but I struggle to see it.
If this is a bug, I hope there can be an update to fix it before the next release. If not, I hope someone has an idea for a workaround.

채택된 답변

Monisha Nalluru
Monisha Nalluru 2021년 4월 23일
From the documentation, it is said the object get their default properties from their ansectors.
If the object has no ancestor, it wont pick the default properties mentioned.
You can query the default properties for object without parenting.
get(groot, 'defaultUIControlFontSize') % return 8
will give the default font size which could then pass to their uicontrol instance as the "FontSize" property
  댓글 수: 1
Roman Müller-Hainbach
Roman Müller-Hainbach 2021년 4월 23일
Yes. My understanding was that even unparented controls were descendents of groot. Apparently this is not true.
It would have been more useful in my opinion to apply groot default settings not only to figure objects but also all unparented graphics aswell.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by