How to create a menu with checkbox in app designer?

40 visualizaciones (últimos 30 días)
rbme17
rbme17 el 30 de Mzo. de 2020
Editada: rbme17 el 21 de Mayo de 2021
Hi everyone,
I've been working on a gui in app designer for a while now. I'd like to add a top menu bar feature that contains a dropdown menu with four different fields. In each field, I'd like there to be at least two checkboxes. The purpose is for the user to select which units they'd like for their data to be processed and plotted (see image below).
I plan on using the checkbox to indicate which option is selected in each menu, as well as editing a public property that contains conversions to use within some code. When one checkbox is selected in each sub menu, I'd also like to deselect the other checkboxes within the same submenu
(e.g. distance> meters[x], feet[ ] --> distance> meters[ ], feet [x])
I've read the matlab documentation from this link https://www.mathworks.com/help/matlab/ref/uimenu.html, but I don't understand how to create the checkbox option in app designer.
Can someone explain to me how to do so in design view/code view ?
Sample of menu (meters and feet should be checkboxes):

Respuesta aceptada

Mohammad Sami
Mohammad Sami el 31 de Mzo. de 2020
There is a property "Checked" for uimenu.
In app designer select the menu and in property inspector tick the checked box.
  3 comentarios
MCL MATLABFOUR
MCL MATLABFOUR el 20 de Mayo de 2021
When I check the checked box and run the code, it does not give me the option to check or uncheck the box. Do you know how to fix that? I would like to give the user to check certain options but not have to check all of the boxes
rbme17
rbme17 el 20 de Mayo de 2021
Editada: rbme17 el 21 de Mayo de 2021
The 'Checked' box in the image Mohammad posted is the initialization - whether it's checked upon start of your app.
You'll want to use the menu item property 'Checked' for change it's checked status.
app.MenuTitle.Checked = 'on'
app.MenuTitle.Checked = 'off'
If you want it to toggle on/off when clicking the button, you'll want to set something up like below. This concept can be applied to turn off other menu checks upon clicking or interacting with other appdesigner buttons, menus, etc.
isChecked = app.MenuTitle.Checked;
if isequal(isChecked,'on'
app.MenuTitle.Checked = 'off'
elseif isequal(isChecked,'off')
app.MenuTitle.Checked = 'on'
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by