Submenu & Menu Handling / Reference in Callback Function
2 views (last 30 days)
Show older comments
Hi, I'm currently trying to reference back to a submenu of a menu that I created using loops. How can I do that?
%Populate / Create Menu & Submenu
FIRST.menu = uimenu('Label','FIRST');
for i = 1:1:length(A)
SECOND.menu = uimenu('Parent',FIRST.menu,'Label',A(i))
for j = 1:1:length(B)
THIRD.menu = uimenu('Parent',SECOND.menu,'Label',B(j))
for k = 1:1:length(C)
THIRD.choices(k) = uimenu(THIRD,'Label',C(k),'Callback',@Callback)
end
end
end
function Callback(eventobject,~)
%How can I reference to a specific submenu in the callback function?
%Like if Option 2 of the FIRST Menu was "expanded" then Option 3 of
%the SECOND Menu was "expanded" and finally Option 4 of the "THIRD"
%Menu was clicked on, how can I refer back to the menus and find out which
%ones were selected(Not the selected options but the respective menus)?
0 Comments
Accepted Answer
Walter Roberson
on 4 Jun 2013
Your THIRD.choices should have 'Parent', THIRD.menu
Within your routine "Callback", you can check the Parent property to trace back to find out what was selected above, and the Parent of that, and so on. And you can check the Label at each level.
0 Comments
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT-Files 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!