1 Introduction to MATLAB 2009a Class Event Properties
Classes in MATLAB 2009a can have multiple events. After the classdef command line you must define your class properties, then methods, and finally events. All available attributes are listed in the event properties table.
1.1 What is an Event?
Events represent changes or actions that occur within class instances. For example,
- Modification of class data
- Execution of a method
- Querying or setting a property value
- Destruction of an object
Basically, any activity that can be detected programmatically can generate an event and communicate information to other objects.
MATLAB classes define a process that communicates the occurrence of events to other objects that need to respond to the events. The event model works this way:
- A handle class declares a name used to represent an event. Naming Events
- After an instance of the event-declaring class is created, you can attach listener objects to it. Ways to Create Listeners
- A class method call broadcasts a notice of the event to listeners and the class user is responsible for determining when to declare that the event has occurred. Triggering Events
- Listeners execute a callback function when notified that the event has occurred. Defining Listener Callback Functions
- Listeners can be bound to the lifecycle of the object that defines the event or limited to the existence and scope of a listener object. Ways to Create Listeners
1.2 Example Event Definitions
Events are defined after properties and methods. You can create an event listener using the MATLAB addlistner command.
classdef ... % Public properties ... end ... methods ... end ... events ... end
See the psdData Class Example for more information.
2 Table of Class Event Properties
|Name read only|
Name of the event.
|Description read only|
Currently not used
|DetailedDescription read only|
Currently not used
If true, the event does not appear
in the list of events returned by the events function(or other event listing functions or viewers)
Determines where you can create listeners for the event.
Determines where code can trigger the event.
|DefiningClass||The meta.class object representing the class that defines this event.|
MATLAB 2009a Help
- Events and Listeners - Concepts
- Event Properties
4 MATLAB Related Books