标签:matlab gui 右键菜单 contextmenu
实例步骤:
需要设置UIContextMenu,否则点击右键不显示。
右键点击第一个菜单之后:(在菜单中添加相应的回调函数)
function r1_Callback(hObject, eventdata, handles) % hObject handle to r1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uicontrol(gcf,'style','text','String','右键菜单');
使用底层代码添加右键菜单:
figure('MenuBar','none');%将原来的菜单取消掉 h=uicontextmenu;%定义新的右键菜单 uimenu(h,'label','右键菜单1');%定义子菜单 uimenu(h,'label','右键菜单2');%定义子菜单 set(gcf,'uicontextmenu',h);%将右键菜单显示出来
Matlab学习------------带有右键菜单的GUI学习实例
标签:matlab gui 右键菜单 contextmenu
原文地址:http://blog.csdn.net/z1137730824/article/details/38775683