Notifications

Notifications are used to notify about some changes and supported by iv.window, iv.node, iv.texture. These objects have common functions to add and remove event listeners.

Functions

.addRefTarget(f)

Method registers the specified function or object as notification callback.

f notification function or object with onNotify method

Function receives one event object as argument with following properties:

code type of notification event. For list of possible values see following page.
wnd/source 3d window uses wnd filed as source of notifications Rest objects use source field. In all cases meaning is same - source of notification.
doDef [Optional], if this property exists, you may set it to false in order to stop default processing.
... There are more, event specific values.

If the method succeeds, the return value is true.

.removeRefTarget(f)

Method removes the specified function or object from list of notification listeners.

f notification function or object with onNotify method

Event Handlers

Event may be handled by function or by object with onNotify function. Second method may slightly simplify code.

Sample function as notification callback

 var t=this;
node.addRefTarget(function(event)
	{
	 switch(event.code)
	{
	 case "state":if((event.source.state&3)!=(event.old&3))t._updateVisibility(item);break;
	}
	});

Sample object as notification callback

 iv.textNode.prototype.onNotify=function(event) {
	if(event.code=="ready"){
	this.update();
	if(this.window) this.window.invalidate(iv.INV_VERSION);
	}
}
..
f.addRefTarget(this);

In this article