Multiple callbacks to one callback
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Juan Ruiz Osorio
am 7 Okt. 2020
Kommentiert: Juan Ruiz Osorio
am 9 Okt. 2020
Hi, everyone,
I'm doing an app in the App designer and I got the following problem. I have some components and I need to do some process (always the same) when any of the components value changes. I would like to know if there is a way to put everything together in the same callback. This is something that will help me to avoid repetition of lines in the code.
I'm doing something like
ValueChanged callback in component one
Calculation ComponentOne.Value+ComponentTwo.Value
ValueChanged callback in component two
Calculation ComponentOne.Value+ComponentTwo.Value
What I would like to do is
ValueChanged callback in component one or two
Calculation ComponentOne.Value+ComponentTwo.Value
Thanks in advance
1 Kommentar
Akzeptierte Antwort
Mohammad Sami
am 8 Okt. 2020
You can assign the same function as callback to multiple ui components.
Inside you function you will need to be able to access the properties under app directly.
function CommonValueChanged(app, event)
app.ComponentOne.Value + app.ComponentTwo.Value
end
5 Kommentare
Mohammad Sami
am 9 Okt. 2020
Thats not what I meant.
You can right click on each component on the right hand pane.
For the first component, click add value changed fcn to create a callback. For the second component, Click Select Exisiting Callback and set it to same callback as one.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/375431/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/375433/image.png)
I have also attached a small demo.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!