Creating callbacks to children in menus

1 次查看(过去 30 天)
Hello All,
I am trying to create the same callback for each of the children in a menu bar. When the function getfile is called, several children are populated to the "Open User Setting menu bar". Now, when I run the app and click one of the children menus, I would like to call the function "settingSelected(app)" and load the file "name" to a struct called var. However, I haven't been able to make the settingSelected function to work.
Any help would be great.
Thanks!
function getfile(app)
files = dir(fullfile('path where I saved files', '*.mat'));
for i = 1:size(files,1)
app.mitem = uimenu(app.OpenUserSettingsMenu,'Text',files(i).name); % creates childrens (with the names of the files inside path) for Open User Settings menu bar
app.mitem.MenuSelectedFcn = @setttingSelected(app,files(i).name)
end
end
function settingSelected(app,name)
var = load(name);
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by