Two windows pop up when I call uigetdir from appdesigner app
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
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 Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!