|
楼主 |
发表于 2006-9-30 17:09
|
显示全部楼层
我试验的例子如下
Main_menu=uicontextmenu; % 定义一个快捷菜单
hline=plot(1:10,'UIContextMenu',Main_menu); % 定义一条曲线并且关联一个快捷菜单
% 以下的cb开头的是为菜单项定义回调函数
cb11=['set(hline,"LineStyle","--")'];
cb12=['set(hline,"LineStyle",":")'];
cb13=['set(hline,"LineStyle","-")'];
cb21=['set(hline,"color","b")'];
cb22=['set(hline,"color","r")'];
cb23=['set(hline,"color","k")'];
% 以下定义快捷菜单
cmenu1=uimenu(Main_menu,'Label','点型');
item11=uimenu(cmenu1,'Label','dashed','Callback',cb11);
item12=uimenu(cmenu1,'Label','dotted','Callback',cb12);
item13=uimenu(cmenu1,'Label','solid','Callback',cb13);
cmenu2=uimenu(Main_menu,'Label','颜色');
item21=uimenu(cmenu2,'Label','蓝色','Callback',cb21);
item12=uimenu(cmenu2,'Label','红色','Callback',cb22);
item12=uimenu(cmenu2,'Label','黑色','Callback',cb23); |
|