www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/+mbcgui/+hgclassesutil/addprop.m
function P = addprop(obj, PropName, varargin) %ADDPROP Add a dynamic property to an object. % % P = ADDPROP(OBJ, PROPNAME) adds the property with the name PROPNAME to % obj. The property meta object will be returned. OBJ may be either an % MCOS handle or a UDD handle and the class of P will depend on which % input class system is used. If the property is on a UDD object, the % type will be set to 'MATLAB array' as this matches the only type % available in MCOS. % % P = ADDPROP(OBJ, PROPNAME, ATTRIBNAME, ATTRIBVALUE, ...) specifies % additional attribute property-values that are set on the property. % Valid options are: % % Hidden : Set whether the property is publicly visible (boolean). % GetMethod : Handle to a function to call when the property is % retrieved. % SetMethod : Handle to a function to call when the property is set. % % Notes: % (1) The syntax and usage of MCOS and UDD Set and Get functions is % slightly different: in MCOS you must set the property yourself but in % UDD you must return a modified value and the set is done for you. % The set/get functions here are modelled on the MCOS way, whether the % input object is MCOS or UDD. % Copyright 2008-2014 The MathWorks, Inc. obj = mbcgui.hgclassesutil.toHandle(obj); P = addprop(obj, PropName); % Consistent with UDD behaviour P.SetObservable = true; P.AbortSet = true; for n=1:2:length(varargin) P.(varargin{n}) = varargin{n+1}; end