matlab.metadata.Event - Describe event defined by MATLAB class - MATLAB (original) (raw)

Namespace: matlab.metadata
Superclasses: matlab.metadata.MetaData

Describe event defined by MATLAB class

Renamed from meta.event in R2024a

Description

The matlab.metadata.Event class provides information about MATLAB® class events. Properties of the matlab.metadata.Event class correspond to event attributes and other information that is specified syntactically in the class definition. All properties are read-only.

The matlab.metadata.Event class is a handle class.

Class Attributes

Abstract true
ConstructOnLoad true

For information on class attributes, see Class Attributes.

Creation

You cannot instantiate a matlab.metadata.Event object directly. Obtain amatlab.metadata.Event object from the matlab.metadata.Class EventList property, which contains an array ofmatlab.metadata.Event objects, one for each event defined for the class. For example, replace ClassName with the name of the class whose events you want to query:

mco = ?ClassName; elist = mco.EventList; elist(1); % matlab.metadata.Event for first event in list

Use the metaclass function to obtain amatlab.metadata.Class object from a class instance:

Properties

expand all

Name of the event, returned as a character vector.

Short description of the event, returned as a character vector. For user-defined classes, the text for this property comes from code comments in the event definition. If there are no comments, the property returns an empty character vector. For more information on how to include help text for your class events, see Custom Help Text.

Detailed description of the event, returned as a character vector. For user-defined classes, the text for this property comes from code comments in the event definition. If there are no comments, the property returns an empty character vector. For more information on how to include help text for your class events, see Custom Help Text.

Value of event attribute Hidden, returned as a logical value. Iftrue, the event does not appear in the list of events returned by the events function (or other event listing functions or viewers).

What code can listen to this event, returned as:

What code can trigger this event, returned as:

Class that defines this event, returned as a matlab.metadata.Class object.

Examples

Find Event NotifyAccess

Find what code can trigger theObjectBeingDestroyed event of thematlab.mixin.Copyable class. Use the matlab.metadata.Event object to determine the event NotifyAccess.

mc = ?matlab.mixin.Copyable; findobj(mc.EventList,"Name","ObjectBeingDestroyed").NotifyAccess

Version History

Introduced in R2008a

expand all

The namespace and class name of meta.event have been changed tomatlab.metadata.Event. The behavior remains the same.

MATLAB will continue to recognize the old metaclass names in most contexts. However, code that relies on string comparisons to identify metaclasses might need to be updated to continue to work as expected. For example, if mObj in the example below is a matlab.metadata.Event instance, the code under the case statement for 'meta.event' does not execute becauseclass(mObj) returns 'matlab.metadata.Event'.

switch class(mObj) case 'meta.event' % code to execute if mObj is a meta.event instance ... end

To ensure this code continues to work as intended, use an if statement with isa. The isa command recognizes both the old and new names of the class.

if isa(mObj,'meta.event') % code to execute if mObj is a matlab.metadata.Event instance else ... end

If compatibility with older releases of MATLAB is not a concern, you can update 'meta.event' to'matlab.metadata.Event'. However, continue to use the old name if your code needs to run on versions of MATLAB before R2024a.

For user-defined classes with appropriately placed code comments, theDescription and DetailedDescription properties are populated with text pulled from those comments. For more information on how to use code comments to store custom help text for user-defined classes, see Custom Help Text.