Callback function not found for dynamically created app UI component
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Monika Jaskolka
el 20 de Mzo. de 2021
Respondida: Bear
el 15 de Nov. de 2021
I would like to dynamically/programmtically create a uidropdown component that calls a function when its value is changed. However, even though I provide a function handle as the ValueChangedFcn property, the uidropdown is unable to find the function. I receive the error below.
Undefined function 'DropDownChange' for input arguments of type 'matlab.ui.control.DropDown'.
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 305)
Error while evaluating DropDown PrivateValueChangedFcn
I am attaching a simple app created in R2016b that exhibits this behavior. Why can't the function be found? How should I define it to resolve the issue?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/556327/image.png)
2 comentarios
Jan
el 20 de Mzo. de 2021
Please post code as text, such that writing an answer allows to copy&paste.
Monika Jaskolka
el 20 de Mzo. de 2021
Editada: Monika Jaskolka
el 20 de Mzo. de 2021
Respuesta aceptada
Más respuestas (2)
Jan
el 20 de Mzo. de 2021
Editada: Jan
el 20 de Mzo. de 2021
As far as I can see, Matlab searchs for a matching function with the input (app, event), but your callback accepts (app) only. So try to append a 2nd (unused...) input to your CropDownChange function.
[EDITED] No, this does not work.
1 comentario
Monika Jaskolka
el 20 de Mzo. de 2021
Editada: Monika Jaskolka
el 20 de Mzo. de 2021
Bear
el 15 de Nov. de 2021
I have a similar issue.
I'm creating a submenu voice with a file path and I want to associate a function. The idea is the add a voice every time the user selects a directory in order to have a history of selected folders.
I would like to catch also the event when the user selects a folder in order to retrieve the selected path and move to that folder.
mitem = uimenu(app.RecentpathsMenu,"Text",user_dir,"MenuSelectedFcn",@(~,~)app.ChangePath);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/801084/image.png)
0 comentarios
Ver también
Categorías
Más información sobre Develop uifigure-Based 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!