MATLAB Object-Oriented Programming

(Joyce) #1

  1. The notify method triggers an
    event, and a message is broadcast.

  2. The callback function is executed.

  3. A listener awaiting the message
    executes its callback.

  4. Setting the property runs a set access method,
    which, in turn, executes notify.

  5. A property is assigned a new value. myfunceval


Properties
FofXY

Methods

Events
UpdateGraph

set.FofXY

Listener

Properties
EventName = ‘UpdateGraph’
FunctionHandle = @listenUpdateGraph

myfuncview

Methods
listenUpdateGraph

UpdateGraph

obj.FofXY = @(x,y)x^2+y^2

function set.FofXY(obj,func)
obj.FofXY = func;
notify(obj,’UpdateGraph’);
end

The fcnview class defines a listener for this event. When fcneval triggers the event,
the fcnview listener executes a callback function that performs the follow actions:


  • Determines if the handle of the surface object stored by the fcnview object is still
    valid (that is, does the object still exist)

  • Updates the surface XData, YData, and ZData by querying the fcneval object's
    Data property.


The fcneval class defines an event name in an event block:

Techniques for Using Events and Listeners
Free download pdf