How can I use uigetfile when I click on an edit text in a GUI?
1 次查看(过去 30 天)
显示 更早的评论
I have an edit text box that says "Choose the file you would like to import". I would like to be able to click on it and have a file selector open up. I have tried using this:
if handles.edit7.Value==1 %%If i click on it
file=uigetfile('*.txt')
end
as if it was a pushbutton, but it doesn't work.
回答(1 个)
Thiago Henrique Gomes Lobato
2020-4-5
编辑:Thiago Henrique Gomes Lobato
2020-4-5
You can't. Every GUI component has it's own callbacks, for the edit text element you have callbacks such as key press/release and callback after write something but nothing that it is called as soon as you click on it. It you think about it, it makes really no sense to have an edit text that calls a function, otherwise it would be a pushbutton. I really don't see any reason why this could be preffered from a simple pushbutton, specially in respect to the GUI user iteration, it would be just too confusing. If the idea is that the user would be able to edit the path after loading it, it would be way cleaner to have an edit text and a pushbutton at the side of it, then the pushbutton would call the uigetfile function and you could show the path at the edit box and let the user change it.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!