www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/+mbcgui/+hgclassesutil/proplistener.m

    function L = proplistener(obj, hProp, evtname, callback)
%PROPLISTENER Construct a property event listener.
%
%   L = PROPLISTENER(OBJ, PROP, EVENT, CALLBACK) constructs a property
%   listener for the specified property of OBJ.  EVENT must be one of
%   'PreGet', 'PostGet', 'PreSet' or 'PostSet'.  PROP must be  a property
%   metadata object or a property name.  CALLBACK must be a function
%   handle: cell arrays are not allowed.  To construct a safe callback
%   function handle see the MBCUTILS.CALLBACK functions.
%
%   This function will work correctly with both UDD and MCOS objects and
%   will return a listener of a class appropriate for the input object
%   system.  All events will be delivered with a structure that mimics the
%   MCOS system.  Where possible the structure will be a correct MCOS event
%   data object, however this may not always be honoured when the input is
%   a UDD object: in this case the event data will be a Matlab structure.
%
%   Note: this function is a helper for HG conversion work and will be
%   removed in a future release.

%   Copyright 2008-2014 The MathWorks, Inc.


obj = mbcgui.hgclassesutil.toHandle(obj);

if ischar(hProp)
    hProp = obj(1).findprop(hProp);
elseif iscellstr(hProp)
    hPropSrc = obj(1);
    hProp = cellfun(@(p) hPropSrc.findprop(p), hProp, 'UniformOutput', false);
end
L = event.proplistener(obj, hProp, evtname, callback);