필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Spigge
Spigge 2014년 8월 3일
댓글: Spigge 2014년 8월 4일
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?

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 8월 3일
k=uigetdir;
if k==0;
k=[];
end
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2014년 8월 3일
편집: Azzi Abdelmalek 2014년 8월 3일
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))

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by