How do I handle multiple components and callbacks in app designer?
7 views (last 30 days)
Show older comments
Shabnam Noor
on 20 Sep 2023
Edited: Cris LaPierre
on 20 Sep 2023
I am using the Knob and the Slider components in App Designer and I want to use a separate Edit Field box for each to display the values as I change them. I managed to use the callback function to do this for the Knob but when I try to do the same thing for the Slider, the value gets displayed on the same Edit Field box. I want to display the values on separate Edit Field boxes, rather than sharing the same one.
I am having the same problem with multiple Switch and Lamp combinations. I have 2 switches and a separate lamp for each of them but again, the two switches seem to be sharing the same lamp. How do I separate them?
2 Comments
Accepted Answer
Cris LaPierre
on 20 Sep 2023
Edited: Cris LaPierre
on 20 Sep 2023
Each component has its own name. You need to update your code to refer to the specific component. You can view the name(s) in the Component Browser.

In your case, you have componenets app.Lamp and app.Lamp_2, but your code only ever refers to app.Lamp. Update one of your callbacks to use app.Lamp_2.
The same thing is happening with your edit fields. You have componenets app.EditField and app.EditField_2, but your code only uses app.EditField.
2 Comments
Dyuman Joshi
on 20 Sep 2023
Accepting the answer indicates that your problem has been solved (which can be helpful to other people in future) and it awards the volunteer with reputation points for helping you.
You can accept only 1 answer for a question, but you can vote for as many answers as you want. Voting an answer also provides reputation points.
More Answers (0)
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!