multiple default files for uigetfile

6 次查看(过去 30 天)
I selected multiple files with uigetfile. later I call uigetfile again and would like to use the previously selected files as defaults, so that I can easily deselect or add files.
Can anybody help me how to have multiple default files?
  5 个评论
Jan
Jan 2021-3-4
Sorry, Andreas and Mario, did you see my suggestion? It does work as far as I can see.
[file, folder] = uigetfile('*.png','Select an icon file', ...
'"file1.png" "file2.png" "file3.png"')
Mario Malic
Mario Malic 2021-3-4
Yes, it's possible to put it in the uigetfile filter, but when you select another file (with and without Control button), list of files that were in the field are gone.

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2021-3-4
编辑:Jan 2021-3-4
Under Windows this works:
% Select multiple M-files:
[File, Folder] = uigetfile('*.m', 'Choose files', '', 'Multiselect', 'on')
% Provide the files as char vector with double quotes aroud the names:
Default = sprintf('"%s" ', File{:});
Default(end) = []; % Remove trailing space, just to be lean
[File2, Folder2] = uigetfile('*.m', 'Choose files', Default, 'Multiselect', 'on')
% Pressing Enter selects the both default files.
  3 个评论
Jan
Jan 2021-3-5
I see. You are right: Matlab's call to the file chooser dialog does not select the default file oder files. This is a "feature" of the Java FileChooser dialog, which does not offer a method for an initial selection. See: https://stackoverflow.com/questions/33945713/setselectedfilefile-file-does-not-present-selection-in-gui-of-jfilechooser

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by