フィルターのクリア

Two windows pop up when I call uigetdir from appdesigner app

2 ビュー (過去 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 Center および File ExchangeDevelop 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