Dynamic uimenu dropdown list in figure tool bar
Show older comments
I would like to add a dynamic dropdown list of menu items on a figure tool bar the initail list will consist of,
s_commands = {'!LED1','!LED2','!LEDT1','!LEDT2','!RGBW1','!RGBW2',...
'!POSRST','!POSSTR','!NEXT','!SLEEP','!WAKE','!POS','!GO',...
'!HELP','!VERS','!IDN'};
The number of list elements will vary, with between 5 to 20 elements. The following does not seem to work, am I missing something subtle?
figDialog = figure('Toolbar','none');
menuDialog = uimenu('Text','Commands');
menuItems = uidropdown(menuDialog,'Text',s_commands);
I'm a bit new as I havent done any Matlab coding for over 6 years and am unable to find a suitable answer.
Thanks in advance.
Answers (1)
VBBV
on 30 Nov 2020
s_commands = {'!LED1','!LED2','!LEDT1','!LEDT2','!RGBW1','!RGBW2',...
'!POSRST','!POSSTR','!NEXT','!SLEEP','!WAKE','!POS','!GO',...
'!HELP','!VERS','!IDN'};
fig = uifigure;
menuDialog = uimenu(fig,'Text','Commands');
for i = 1:length(s_commands)
menuItems = uimenu(menuDialog,'Text',(s_commands{i}));
end
Try this it works now, It needs a loop to access the cell array contents
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!