www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@roller/copyobj.m

    function newobj=copyobj(obj,fig)
% COPYOBJ  Create a copy of an object in a new figure
%
%   NEWOBJ=COPYOBJ(OBJ,FIG) creates a replica of the object
%   OBJ in the figure FIG.
%

%  Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.



% Created 18/9/2000

newobj=obj;

% copy graphics objects
h=copyobj([obj.frame1;obj.text1;obj.frame2;obj.text2],fig);
newobj.frame1= h(1);
newobj.text1= h(2);
newobj.frame2= h(3);
newobj.text2= h(4);

% set callbacks

set(newobj.text1,'ButtonDownFcn',{@mbcgui.util.legacycallback,@rollcb,newobj.text1});
set(newobj.text2,'ButtonDownFcn',{@mbcgui.util.legacycallback,@rollcb,newobj.text1});

% save copy of object
builtin('set',newobj.text1,'UserData',newobj);