Main Content

event.proplistener

Define listener object for property events

Syntax

lh = event.proplistener(Hobj,Properties,'PropEvent',@CallbackFunction)

Description

lh = event.proplistener(Hobj,Properties,'PropEvent',@CallbackFunction) creates a property listener object for one or more properties on the specified object.

  • Hobj — handle of object whose property or properties are to be listened to. If Hobj is an array, the listener responds to the named event on all objects in the array.

  • Properties — an object array or a cell array of matlab.metadata.Property object handles representing the properties to which you want to listen.

  • PropEvent — must be one of the following: PreSet, PostSet, PreGet, PostGet

  • @CallbackFunction — function handle to the callback function that executes when the event occurs.

The event.proplistener class defines property event listener objects. It is a subclass of the event.listener class and adds one property to those defined by event.listener:

  • Object — Cell array of objects whose property events are being listened to.

You can call the event.proplistener constructor instead of calling addlistener to create a property listener. However, when you do not use addlistener, the listener's lifecycle is not tied to the object(s) being listened to.

The event.proplistener class is a handle class. 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.

See Listen for Changes to Property Values.

See Get Information About Properties for more information on using matlab.metadata.Property objects.

Version History

Introduced in R2008a