Using the Matlab App Designer, How can I hide a numeric field with a button push?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have been attempting to use the Matlab App Designer to create a program GUI. I want to have a button with two options, A or B. If A is selected, a numeric box will pop up with a label, and that numeric will have a variable corresponding to A. If B is selected, I want a different numeric box to pop up, and this box would have a variable associated with B. I am trying to do this within a tab, and do not want to use the figure command as this has created a pop up window. Utilizing an If statement, I have been able to get the boxes to pop up, but if I select button A, and then button B, The button A box does stays open, and the text overlaps. Thank you in advance. App Code Attached:
button = app.ButtonGroup.SelectedObject.Text;
if button(1) == 'A'
% Create EditFieldLabel
appEditFieldLabel = uilabel(app.InputsTab);
appEditFieldLabel.HorizontalAlignment = 'right';
appEditFieldLabel.Position = [210 572 50 15];
appEditFieldLabel.Text = 'A';
% Create EditField
appEditField = uieditfield(app.InputsTab, 'numeric');
appEditField.Position = [275 568 100 22];
delete appEditFieldLabel1
else
% Create EditFieldLabel
appEditFieldLabel1 = uilabel(app.InputsTab);
appEditFieldLabel1.HorizontalAlignment = 'right';
appEditFieldLabel1.Position = [210 572 50 15];
appEditFieldLabel1.Text = 'B';
% Create EditField
appEditField1 = uieditfield(app.InputsTab, 'numeric');
appEditField1.Position = [275 568 100 22];
end
0 comentarios
Respuestas (1)
Freya H
el 13 de Ag. de 2018
You can set the visibility of the other label to 'off' using
app.NameofComponent.Visible = 'off'
I would create both components outside the function (e.g. in the design view) and set their visibility to 'off' (e.g. in the startupfcn).
You can then set the visibility of the component you want to show to 'on' in each of your if/else statements (and the other one to 'off').
0 comentarios
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!