MATLAB Object-Oriented Programming

(Joyce) #1

Property-Set and Query Events


There are four predefined events related to properties:



  • 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


These events are predefined and do not need to be listed in the class events block.


When a property event occurs, the callback is passed an event.PropertyEvent object.
This object has three properties:



  • EventName — The name of the event described by this data object

  • Source — The source object whose class defines the event described by the data
    object

  • AffectedObject — The object whose property is the source for this event (that is,
    AffectedObject contains the object whose property was either accessed or
    modified).


You can define your own property-change event data by subclassing the
event.EventData class. The event.PropertyEvent class is a sealed subclass of
event.EventData.


See “Listen for Changes to Property Values” on page 11-40 for a description of the
process for creating property listeners.


See “The PostSet Event Listener” on page 11-60 for an example.


See “Property Access Methods” on page 8-50 for information on methods that control
access to property values.


Listeners


Listeners encapsulate the response to an event. Listener objects belong to the
event.listener class, which is a handle class that defines the following properties:


Event and Listener Concepts
Free download pdf