How can I retrieve data from a callback of an in-built function?
Afficher commentaires plus anciens
Hello. I am trying to write a script that, when executed, allows the user to click on a button in a dialog box and select a directory. Furthermore, I want to store the directory path as a string. The problem I have is that the 'callback' I am using is to an in-built function and the 'help' I have looked at seems to be for user-created functions.
For example: https://uk.mathworks.com/help/matlab/creating_guis/share-data-among-callbacks.html#bt9p4qp.
I believe the advice on 'guidata' and 'guihandles' is for cases where you can write 'guihandles' into a separate section of code where the function is defined, which I don't have. I saw the same thing in the section for storing data in UserData.
Here is what I have so far:
% Setting up a dialog box
box = dialog('WindowStyle','normal','Name','My Dialog');
% Setting up 'uicontrol'
uicontrol(box,'Style','pushbutton','String','Click here','Position',[50 50 50 50],'Callback',@(src,event)uigetdir('C:\','Pick a folder:'));
So, how can I retrieve the directory path from the callback of the 'uigetdir' function? Any solutions or links to documentation that already has the answer would be greatly appreciated.
Many Thanks.
2 commentaires
Image Analyst
le 23 Juil 2018
Why not simply use GUIDE or App Designer? Why do it the hard way by going into all these gory details yourself?
Manoj Abhishetty
le 23 Juil 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Whos dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!