I have a gui which list two types of things in the menubar. The solution that was found was to limit the number of elements in the context menu to 25 :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% construction menu éléments
function base=CreeMenuElem(noms,base,pref)
global kg4_HndlFig
hm=findobj(kg4_HndlFig,'Tag','Elem0');
delete(get(hm,'children')) %reset du menu éléments
set(hm,'Enable','on') %activation du menu éléments
if pref.CacheElem
noms=noms(~strncmp(noms,'@',1)); %suppression des éléments cachés
end
n=length(noms);
if pref.LimitMenu,MaxMenus=25;else MaxMenus=30;end
ChOld='';k=base;nm=0;
while (k<=n)
Ch=noms{k};
p=strfind(Ch,'::');
if isempty(p)
nm=nm+1; if nm>MaxMenus, break, end
uimenu(hm,...
'Label',Ch,...
'Tag','Element',...
'Callback','kgexec4');
ChOld='';
else
ChNew=Ch(1:p-1);
if ~strcmp(ChOld,ChNew)
nm=nm+1; if nm>MaxMenus, break, end
hb=uimenu(hm,'Label',ChNew);
ChOld=ChNew;
end
uimenu(hb,...
'Label',Ch,...
'Tag','Element',...
'Callback','kgexec4');
end
k=k+1;
end
if (base>1)|(k<n)
uimenu(hm,...
'Label',sprintf('(éléments %g à %g / %g) Suite...',base,k-1,n),...
'Separator','on',...
'Tag','SuiteElements',...
'Callback','kgexec4');
end
if k>n
base=1; %retour au début de la liste
else
base=k;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% construction menu barres
function base=CreeMenuBarr(noms,base,pref)
global kg4_HndlFig
hm=findobj(kg4_HndlFig,'Tag','Barre0');
delete(get(hm,'children')) %reset du menu barres
set(hm,'Enable','on') %activation du menu barres
noms=noms(2:end); %suppression de GND
if pref.CacheBarr
noms=noms(~strncmp(noms,'@',1)); %suppression des noms auto
end
n=length(noms);
if pref.LimitMenu,MaxMenus=25;else,MaxMenus=30;end
bb=min(base+MaxMenus-1,n); %dernier menu à afficher
for k=base:bb
uimenu(hm,...
'Label',noms{k},...
'Tag','Barre',...
'Callback','kgexec4' );
end
if (n>MaxMenus) && pref.LimitMenu
uimenu(hm,'Label',sprintf('(barres %g à %g / %g) Suite...',base,bb,n),...
'Tag','SuiteBarres', 'Separator','on', 'Callback','kgexec4' );
end
if bb<n, base=bb+1; else base=1; end %retour au début de la liste
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I would like to be able to scroll in these menus instead of using this solution that can be impractical and slow but i don't understand how to add the scroll option. I tried with uicontrol but it never works.