How can I use Menu bar for multiple options check?

Hi all
I am trying to create an app on the App Designer.
This app will have the option to be in English and Spanish, so the user may choose the language.
To do this I use the Menu Bar, one option for Spanish and another to English, but when I choose option 1 the option 2 sometimes doesn’t un check or If I check option 2 it doesn’t do anything.
I don’t know what is wrong with the code, I would like that only one option may be checked at time and only when the option is clicked.
This is my code:
app.SpanishMenu.MenuSelectedFcn = @ShowCheck;
function ShowCheck(src,event)
if strcmp(app.SpanishMenu.Checked,'on')
app.SpanishMenu.Checked = 'off';
app.EnglishMenu.Checked = 'on';
disp(app.PropiedadesdelAguaPanel.Title);
set(app.PropiedadesdelAguaPanel, 'Title', 'Water Properties')
set(app.TemperaturaDropDownLabel, 'Text', 'Temperature')
else
%strcmpi(app.EnglishMenu.Checked,'on')
%app.EnglishMenu.Checked.Checked = 'on';
app.SpanishMenu.Checked = 'on';
%app.EnglishMenu.Checked = 'off';
set(app.PropiedadesdelAguaPanel, 'Title', 'Propiedades del Agua')
set(app.TemperaturaDropDownLabel, 'Text', 'Temperatura')
end
end

4 comentarios

Is this line:
app.SpanishMenu.MenuSelectedFcn = @ShowCheck;
in the callbacks for BOTH menu items? ShowCheck() needs to be called when either menu item is clicked. Or are you using a single menu item to handle the checking?
Also, you're setting that equal to the handle to the function but I don't think that actually calls the function - step through with the debugger to make sure. Plus, ShowCheck doesn't seem to return any value at all, so how can you assign anything to app.SpanishMenu.MenuSelectedFcn?
This is a picture of the app, I'm using one Menu Bar with two option, so the user may choose if the app is in spanish or english.
Just one option may be active, but I don't know how to do that, the code lines in the first post are the lines I'm using.
app.jpg
Luna
Luna el 2 de Jul. de 2019
Will you be able to upload as attachment your whole code for me to run?
Thanks for your help.
Enclosed you will find the app file.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.

Productos

Versión

R2019a

Preguntada:

el 24 de Jun. de 2019

Comentada:

el 4 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by