Filter löschen
Filter löschen

How to delete the setting uimenu from the app.contextmenu component

7 Ansichten (letzte 30 Tage)
Yuhao Sun
Yuhao Sun am 24 Aug. 2020
Beantwortet: RITAM BASU am 22 Mär. 2023
Hi, I want to set the uimenu objects in app.contextmenu dynamically. just like following code:
function ContextMenuOpening(app, event)
app.ContextMenu = cmHandle;
uimenu(cmHandle,'Label','Wider');
uimenu(cmHandle,'Label','Inspect');
end
end
The problem is that the app.contextMenu will save all added uimenu in every funtion calling and never drop repeated items. I need a answer to clear all children in app.ContextMenu.
Thanks a lot!
Yuhao Sun

Antworten (2)

Voss
Voss am 10 Jan. 2023
"I need a answer to clear all children in app.ContextMenu."
delete(app.ContextMenu.Children)

RITAM BASU
RITAM BASU am 22 Mär. 2023
I solved the menus getting repeated with every click by using an "if" statement to check the children (menus) are already there or not,
if isempty(app.ContextMenu.Children)
text = "your menu text";
m1 = uimenu(app.ContextMenu,'Text',text);
end

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by