Effacer les filtres
Effacer les filtres

How can I avoid displaying "0" in my text box when cancel is pressed using UIGETDIR

2 vues (au cours des 30 derniers jours)
Spigge
Spigge le 3 Août 2014
Commenté : Spigge le 4 Août 2014
Hi,
The dialog box UIGETDIR returns either the selected folder name as a string if OK is pressed or the number 0 if Cancel is pressed. In my application I have an edit box with a callback function that calls UIGETDIR and then displays the selected folder string, something like this:
editboxhandle.callbackfcn = @set(editboxhandle,'String',uigetdir);
However, when Cancel is pressed, "0" is displayed in my edit box but while I would like the string to be empty in such case. I'm am restricted to a singel expression callback like the one above. How can I solve this?

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 3 Août 2014
k=uigetdir;
if k==0;
k=[];
end
  3 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 3 Août 2014
Modifié(e) : Azzi Abdelmalek le 3 Août 2014
Why do you need to do it in a single line?
k=uigetdir;
if k==0;
k=[];
end
editboxhandle.callbackfcn = @char(set(editboxhandle,'String',k))

Connectez-vous pour commenter.

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by