Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

event.hasListener

Determine if listeners exist for event

Syntax

tf = event.hasListener(src,EventName)

Description

example

tf = event.hasListener(src,EventName) returns true if listeners exist for the specified event on the object src. Otherwise, it returns false. When src is an array, event.hasListener returns a logical array the same size as src.

The class of src must define or inherit the specified event. If src is a heterogeneous array, the specified event must exist on the class of the array. event.hasListener cannot find listeners for events that are defined by some, but not all objects in the heterogeneous array.

event.hasListener respects the value of the event.listener object Enabled property. If you set the listener Enabled property to false, event.hasListener returns false for that listener.

Examples

collapse all

Determine if there are there listeners for MyEvent on object src:

tf = event.hasListener(src,'MyEvent');

If tf is true, then one or more listeners are attached to src for event MyEvent.

Input Arguments

collapse all

Event source, specified as a scalar or array of objects. The event source is the object to which the listener is attached.

Event name, specified as a char array.

Output Arguments

collapse all

true if listeners exist for the specified event on the specified objects. false if listeners do not exist.

Data Types: logical

Limitations

  • event.hasListener must have NotifyAccess for the event in question.

  • event.hasListener does not work with the predefined property events, PreSet, PostSet, PreGet, PostGet.

  • event.hasListener does not work with the predefined dynamic property events PropertyAdded and PropertyRemoved.

  • Use event.hasListener only with user-defined events.

Introduced in R2016a

Was this topic helpful?