How to check if button is pressed in app designer?

70 visualizaciones (últimos 30 días)
William Pang
William Pang el 20 de Jul. de 2020
Comentada: 지아 백 el 8 de Dic. de 2022
Hi! So I've designed an app for doing some image processing, as shown below:
So I want users to be able to load images by pressing either "Single Image" or "Multiple Images". Once the images are loaded, users can then input values into "Filter Size", "threshold", and "Cut Cells Size" and then press the "Compute button".
However, I want my app to run a different code depending on whether the user pressed "Single Image" or "Multiple Image" upon pressing "Compute". I'm having a bit of trouble making this work, and I'm wondering why the below code doesn't work:
function ComputeButtonPushed(app,event)
if app.SingleImageButtonPushed.Value == 1;
%Run this code
elseif app.MultipleImagesButtonPushed.Value ==1;
%Run this code
end
  2 comentarios
Mohammad Sami
Mohammad Sami el 21 de Jul. de 2020
Are the buttons you used of the type "toggle buttons" ?
Also I assume the user should not be allowed to press both buttons. Therefore you might want to put the two toggle buttons inside the button group.
지아 백
지아 백 el 8 de Dic. de 2022
Hello
I've tried to solve this problem too, but it doesn't work.
Did you solve it?

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 21 de Jul. de 2020
A simple solution would be to create a property in the app, say something like "app.isSingle". If the "Single Image" button is pressed, its callback code sets the value of this property to "true". If "Multiple Images" is pressed, its callback sets the value to "false". Use this value in the logic of your if statement in the callback function for "Compute".

Categorías

Más información sobre Migrate GUIDE Apps 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!

Translated by