MATLAB Object-Oriented Programming

(Joyce) #1

  • SourceOfEvent — An object of the class that defines the event. The event is
    triggered on this object.

  • EventName — The name of the event defined in the class events code block.

  • @listenerCallback — a function handle referencing the function that executes in
    response to the event.


For example, create a listener object for the StateChange event:


function lh = createListener(src)
lh = addlistener(src,'StateChange',@handleStateChange)
end


Define the callback function for the listener. The callback function must accept as the first
two arguments the event source object and an event data object:


function handleStateChange(src,eventData)
...
end


See Also


Related Examples



  • “Listener Lifecycle” on page 11-28

  • “Implement Property Set Listener” on page 11-11


See Also
Free download pdf