필터 지우기
필터 지우기

Two windows pop up when I call uigetdir from appdesigner app

조회 수: 3 (최근 30일)
Josh Zagorski
Josh Zagorski 2020년 3월 4일
댓글: Walter Roberson 2020년 3월 5일
When i call uigetdir from appdesigner two windows pop up, as well as lock up sometimes when selecting a DIR. Every time two Windows pop up, but it only locks up sometimes. By locking up, I select the folder I would like (twice), then, I can't do anything in the app or appdesigner windows, but I can still use any other MATLAB windows with no issues.
function FileDirEditFieldValueChanging(app, event)
fileDir = uigetdir('C:\')
app.FileDirEditField.Value = fileDir;
end
When it does work, I also get the following output:
fileDir =
'%filepath I want%'
fileDir =
'%filepath I want%'
I would also like it to pop up (with ONE window) when you click on the Edit Field vs. on Value Changing. Should I be using a different element? "Edit Field (Text)" looks like the best option

채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 4일
I wonder --
In some cases, "change" callbacks are invoked when you click or type on an edit field, to deal with the fact that you are changing "away" from what the contents used to be. And in some cases, "change" callbacks are also invoked after you set a new value for the field, indicating that the field has "changed".
In most situations that I can think of, setting a value directly by assignment or set() does not invoke a change callback. However, I can think of at least one way of configuring callbacks where callbacks can get invoked after an assignment or set() .
My recommendation would be to have a button to signal that you wanted uigetdir() to be brought up and the result written into the edit field, rather than having an edit callback the way you have. The edit callback should be for validating things the user typed in by hand.
  댓글 수: 4
Josh Zagorski
Josh Zagorski 2020년 3월 4일
I clicked into the Text Box and pressed space once and always two windows pops up, I pressed asdf and again two windows pop up.
Walter Roberson
Walter Roberson 2020년 3월 5일
Is there any documented circumstance under which the Value Changing callback is invoked less than twice? Is your current code prepared for being invoked more than once?
What you are looking for is a variety of "value is starting to change" callback. That does not exist, however.
There just might be a way to work such a callback using event listeners, but I do not know enough about how App Designer works to say whether that could be done or not.
I offered you a work-around: the flag that you reset when the edit is confirmed by the ValueChanged callback.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by