Set uifigure defaults doesn't work the same as figures

with figures I can set the defaults using
set(groot, 'defaultFigurePosition', [1 1 1 1])
but I can not do the same for uifigures
set(groot, 'defaultuiFigurePosition', [1 1 1 1])
Error using matlab.ui.Root/set
uifigureposition is an invalid class name
This is also an issue with the new components i want to use uifigures for, like uilabel, or uieditfield.
Is there something i am doing wrong with the new uifigures when trying to set the defaults?

 Respuesta aceptada

In Summary:
Both UIFigures and Figures are matlab.ui.Figure and so both use the defaults defined similar to
set(groot, 'defaultFigureUnits', 'normalized')
However there seems to be a bug and UIFigures are not currently use these defaults and a ticket has been submitted.
The new ui comonents like uilabel (which is a matlab.ui.label) do not have a units property like the uicontrol('style', 'text') do.
When setting defaults, use
class(uilabel)
class(uifigure)
to figure out the class name for use in the set(groot) command

Más respuestas (1)

Matt Butts
Matt Butts el 18 de En. de 2023
Movida: Adam Danz el 18 de En. de 2023
I believe both figure and uifigure use the same default. Are you seeing thet uifigures are not utilizing your default that you set in DefaultFigurePosition?

7 comentarios

As Matt mentioned, figure and uifigure use the same defaultFigurePosition. Please let us know if you are experiencing any issues with that.
I can set the default color
set(groot, 'defaultFigureColor', [1 1 1])
and both figures and uifigures created use that value. However if i change the default units
set(groot, 'defaultFigureUnits', 'normalized')
figures use the correct default but uifigures still use pixels. Similarly, if i set the default units for uipanel, uipanel's created in figures use the correct default, but those created in uifigures do not.
I can set the default of uicontrol's, but not of the new components that i want to use uifigures for, like uilabel
set(groot, 'defaultUIControlUnits', 'normalized')
set(groot, 'defaultUILabelUnits', 'normalized')
Error using matlab.ui.Root/set
uilabelunits is an invalid class name
a = uicontrol()
b = uilabel()
class(a)
class(b)
You will find that class(a) is matlab.ui.control.UIControl and class(b) is matlab.ui.control.Label . That is, there is a class named UIControl but there is no class named UILabel
Thanks for the details @Steve Zissou.
The uipanel units are affected by the parent units.
fig = figure();
fig.Units % normalized
p1 = uipanel(fig);
p1.Units % normalized
uifig = uifigure();
uifig.Units % pixels
p2 = uipanel(uifig);
p2.Units % pixels
Thanks for the info about DefaultFigureUnits in uifigures. That seems to have changed in R2022a. I've submitted a support ticked to address this.
if class(b) is matlab.ui.control.Label, is there some way to edit its defaults?
set(groot, 'defaultLabelUnits', 'normalized')
Error using matlab.ui.Root/set
labelunits is an invalid class name
matlab.ui.control.Label objects do not have a public units property. This prevents you from setting uilabel units.
Ah okay, yes i see that matlab.ui.control.Label does not have a public units property. However it does have a public position property, and i get the same error when trying to set its default. Should this be possible?
set(groot, 'defaultLabelPosition', [1 1 1 1])
Error using matlab.ui.Root/set
labelposition is an invalid class name

Iniciar sesión para comentar.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Productos

Versión

R2022a

Etiquetas

Preguntada:

el 17 de En. de 2023

Respondida:

el 23 de En. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by