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

조회 수: 11 (최근 30일)
Yuhao Sun
Yuhao Sun 2020년 8월 24일
답변: RITAM BASU 2023년 3월 22일
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

답변 (2개)

Voss
Voss 2023년 1월 10일
"I need a answer to clear all children in app.ContextMenu."
delete(app.ContextMenu.Children)

RITAM BASU
RITAM BASU 2023년 3월 22일
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

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by