Custom 'uimenu' concatenates each time GUI is run
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I've just started working on writing GUIs without using GUIDE. Each time I run my GUI function that has a custom dropdown uimenu (i.e.[File Edit Search], the uimenu keeps concatenating onto the figure unless I close the figure window out completely.
For instance, after running the function twice, the menu bar reads [File Edit Search File Edit Search].
I have tried setting the 'menubar' property to 'none', and I've tried clearing the uimenu handle at the beginning of the function. Nothing seems to work.
Here is some example code taken from the mathworks website. If you drop this into the editor and run it a few times without closing the figure, you'll end up with a figure with multiple finds in the menu bar. Thanks in advance.
f = figure(22);
set(f, 'MenuBar','None');
mh = uimenu(f,'Label','Find');
frh = uimenu(mh,'Label','Find and Replace ',...
'Callback','goto',...
'Accelerator', 'Q');
frh = uimenu(mh,'Label','Variable','Separator', 'on' );
uimenu(frh,'Label','Name', ...
'Callback','variable');
0 comentarios
Respuestas (2)
Sean de Wolski
el 29 de En. de 2013
Every time you call:
mh = uimenu(f,'Label','Find');
It adds another menu. If you instead want to overwrite or delete the existing menu either delete() it or set() its properties to be something else.
f = figure(22);
set(f, 'MenuBar','None');
if exist('mh','var') %if it's there, delete it.
delete(mh);
end
mh = uimenu(f,'Label','Find');
frh = uimenu(mh,'Label','Find and Replace ',...
'Callback','goto',...
'Accelerator', 'Q');
frh = uimenu(mh,'Label','Variable','Separator', 'on' );
uimenu(frh,'Label','Name', ...
'Callback','variable');
0 comentarios
Kris
el 20 de Nov. de 2014
It is quite simple like this:
existingmenus = findall( hfig, 'Type', 'uimenu' );
arrayfun(@(x) delete(x), existingmenus);
Cheers,
K
0 comentarios
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!