App Designer: Using app.Component.Value vs. event.Value in callback function
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Delaney
il 9 Set 2022
Risposto: Walter Roberson
il 9 Set 2022
I am writing a callback function in App Designer where the user has selected an option from a drop-down menu. It seems to me that there are two ways to obtain the value that the user has selected.
Let us say that I have a callback function
function DropDownValueChanged(app, event)
that refers to my UI component DropDown. It seems to me that there are two ways to get the value that was selected from the drop-down menu. According to the section "Callback Input Argments" of this help page, the options are:
value = event.Value;
or
value = app.DropDown.Value;
Is there any tradeoff between using these two approaches? Why even pass event as an argument to the callback function if the same data is stored in app.Component?
0 Commenti
Risposta accettata
Walter Roberson
il 9 Set 2022
You can code the exact same callback for multiple components. You would not know immediately which component the event was for. It might not even have a particular name: it might be part of an array of objects. Using the event information gets you what you need immediately.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!