What is Incisor?
Tutorials
Key Concepts
Reddit
Stack Overflow
Deprecation Schedule

FocusChangeInfo

Object containing information about a change to the 'nc.singularFocusObject' value. An instance of this object is sent as a first parameter to all callbacks registered with the nc.appEvents.focusChange AppEvent. [NON-INSTANTIABLE]

FocusChangeInfo

MEMBERS

objectGainingFocus :object

A reference to the new nc.singularFocusObject.

Example:
// Objective: Add a callback to the focusChange AppEvent.
// Expected Result: After waiting 5 seconds, the console should have 3 log messages as follows:
//    changing focus to Scene2
//    object gaining focus Scene2
//    object losing focus Scene1

// Create 2 scenes, "Scene1" and "Scene2"
this.scene1 = new Scene("Scene1");
this.scene2 = new Scene("Scene2");
// Set the singular focus to "Scene1"
nc.singularFocusObject = this.scene1;

// Create a callback to handle the focus change. Name is "focusChangeCallback".
this.focusChangeCallback = function(args) {
   console.log("object gaining focus", args.objectGainingFocus.name);
   console.log("object losing focus", args.objectLosingFocus.name);
}
// Get an instance of the focusChange AppEvent and add the focus change callback.
this.focusChangeEvent = nc.appEvents.focusChange;
this.focusChangeEvent.addCallback( this, "focusChangeCallback" );

// Create a focus changer that will change the singular focus.
this.focusChanger = function(args) {
   console.log("changing focus to Scene2");
   nc.singularFocusObject = this.scene2;
}
// Use nc.waitThen() to wait 5 seconds before executing the focus changer.
nc.waitThen( 5, this, "focusChanger" );

objectLosingFocus :object

A reference to the previous nc.singularFocusObject.

Example:
// Objective: Add a callback to the focusChange AppEvent.
// Expected Result: After waiting 5 seconds, the console should have 3 log messages as follows:
//    changing focus to Scene2
//    object gaining focus Scene2
//    object losing focus Scene1

// Create 2 scenes, "Scene1" and "Scene2"
this.scene1 = new Scene("Scene1");
this.scene2 = new Scene("Scene2");
// Set the singular focus to "Scene1"
nc.singularFocusObject = this.scene1;

// Create a callback to handle the focus change. Name is "focusChangeCallback".
this.focusChangeCallback = function(args) {
   console.log("object gaining focus", args.objectGainingFocus.name);
   console.log("object losing focus", args.objectLosingFocus.name);
}
// Get an instance of the focusChange AppEvent and add the focus change callback.
this.focusChangeEvent = nc.appEvents.focusChange;
this.focusChangeEvent.addCallback( this, "focusChangeCallback" );

// Create a focus changer that will change the singular focus.
this.focusChanger = function(args) {
   console.log("changing focus to Scene2");
   nc.singularFocusObject = this.scene2;
}
// Use nc.waitThen() to wait 5 seconds before executing the focus changer.
nc.waitThen( 5, this, "focusChanger" );