| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
lh = addlistener(Hsource,'EventName',callback)
lh = addlistener(Hsource,property,'EventName',callback)
lh = addlistener(Hsource,'EventName',callback)) creates a listener for the specified event.
lh = addlistener(Hsource,property,'EventName',callback) creates a listener for one of the predefined property events. There are four property events:
PreSet — triggered just before the property value is set, before calling its set access method.
PostSet — triggered just after the property value is set.
PreGet — triggered just before a property value query is serviced, before calling its get access method.
PostGet — triggered just after returning the property value to the query
See Defining Events and Listeners — Syntax and Techniques for more information.
Handle of the object that is the source of the event, or an array of source handles.
Name of the event, which is triggered by the source objects.
Function handle referencing a function to execute when the event is triggered.
Character string that can be:
the name of the property
a cell array of strings where each string is the name of a property that exists in object array Hsource
a meta.property object or an array of meta.property objects
a cell array of meta.property objects
If Hsource is a scalar, then any of the properties can be dynamic properties. If Hsource is non-scalar, then the properties must belong to the class of Hsource and can not include dynamic properties (which are not part of the class definition).
For more information, see the following sections:
The GetObservable and SetObservable property attributes in the Property Attributes table.
Handle of the event.listener object returned by addlistener.
To remove a listener, delete the listener object returned by addlistener. For example,
delete(lh)
calls the handle class delete method to delete the object from the workspace and remove the listener.
delete (handle), handle, notify (handle)
![]() | addframe (avifile) | addOptional (inputParser) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |