Index

Index

js/library.framework.js

NEW METHOD OF CALLING FRAMEWORK FUNCTIONS Starting with 2.1.X, we will be deprecating all the old functions. They will stay deprecated for a time, but will eventually be removed.

Each object will have a single function called "callFunction". You will use this to call any of the existing functions, and any new functions going forward.

New functions will only be available via "callFunction".

callFunction(functionName, arguments) functionName - String arguments - Array

Calls a framework function called "functionName", passing in the arguments from the "arguments" array. Each object has this function defined.

Examples:

OrionSystem.callFunction('logToConsole', [1, 'A log message']); // function with a single argument

OrionStarletWindow.callFunction('hide', []); // function with no arguments

OrionTearoffParent.callFunction('createTearoffChildFromURL', ['starlet_key_name', 'www.google.com', 'test tearoff', 100, 100, true]); // function with multiple arguments

OrionDownload.callFunction('setErrorCallback', ['errorObject', 'errorCallbackFunction']); // setting callbacks

NOTE on callbacks called by the framework

There are some restrictions on how the framework can call callbacks in your javascript code. You cannot use anonymous functions. You must pass the string name of the callback function you want the framework to use, not the actual function as you would in native javascript.

When defining a callback you want the framework to call, it must be split into two parts; the object and the function.

For example, if you want the framework to call the function foo.barFunc(), you'll need to pass the string "foo" as the object, and the string "barFunc" as the function.

If you have a toplevel function, just pass an empty string for the object.

If you have a function many objects deep, like foo.bar.spam.funcName, pass the string "foo.bar.spam" as the object, and "funcName" as the function.

This restriction is in place due to how the underlying technology is laid out.

Generic Callback System

Most callbacks sent by the framework use a generic event object to maintain consistancy. The idea is that you can lower the amount of custom callbacks, and just use a single (or a few) callbacks depending on your needs.

The object looks like:

event = { 'eventName': 'nameOfEvent', // custom args for the callback };

Example of a simple callback event(sleep notification):

event = {'eventName': 'systemSleep'};

Example of a less simple callback event(mouse notification):

event = { 'eventName': 'mouseEnter', 'mouseX' : 1186, 'mouseY' : 50 };

Putting it all together:

function someCallback(event) { switch(event.eventName) { case 'systemSleep':

        OrionSystem.logToConsole("system is going to sleep!");
        break;

    case 'mouseEnter':

        OrionSystem.logToConsole('mouseEnter : (' + event.mouseX + ', ' + event.mouseY + ')');
        break;

    default: break;
}

}

Source: