Main Content

event.proplistener Class

Namespace: event
Superclasses: event.listener

Class defining listener objects for property events

Description

The event.proplistener is a subclass of event.listener that defines listener objects for class properties. An event.proplistener object responds to a specific property event by executing a callback function.

The event.proplistener class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

pListener = event.proplistener(eventSource,props,propEventName,callbackFcn) creates a property listener object for one or more properties defined by the source object eventSource and identifies a function handle to the callback function.

Input Arguments

expand all

Event source, specified as a handle object array or a cell array of object handles. Use a cell array when the source objects cannot form a standard array because their classes differ. All source objects must define the specified event.

If eventSource is an array of object handles, the listener responds to the named event on any of the objects in the array.

Properties whose events trigger the listener, specified as a scalar matlab.metadata.Property object or an array of matlab.metadata.Property objects corresponding to properties defined for the objects in eventSource.

The class defining the source property must set the GetObservable and SetObservable property attributes to enable you to listen to the property events.

Name of the property event triggered on the source objects, specified as a character vector or string scalar of one of the four predefined property events: PreSet, PostSet, PreGet, or PostGet. See EventName for more information on these property events.

Callback function, specified by a function handle. For more information, see Listener Callback Syntax

Properties

expand all

Name of the event that the listener responds to when triggered on the specified source objects. This property can take one of four values.

Event NameEvent Occurs
PreSet

Immediately before the property value is set, before calling its set access method

PostSet

Immediately after the property value is set

PreGet

Immediately before a property value query is serviced, before calling its get access method

PostGet

Immediately after returning the property value to the query

Attributes:

GetObservable
true
SetObservable
true

Objects whose properties are being observed, specified as a handle object array or cell array of handle objects.

Attributes:

GetObservable
true
SetObservable
true
Dependent
true

Tips

  • addlistener creates a listener that is tied to the lifecycle of the objects being listened to. However, creating a listener by calling the event.proplistener constructor or calling listener creates a listener that is not tied to the lifecycle of the objects.

  • The event.proplistener and the event.listener classes are part of the same heterogeneous hierarchy. Therefore, you can create arrays that contain objects of both classes. The class of an array containing both classes of objects is event.listener.

Version History

Introduced in R2008a