Top  | Previous | Next

Component Extension Functions

Some components may expose functions that can be extended using scripting. These functions will be called by the component itself when appropriate. For example, the Table component exposes an extension function called getBackgroundColorAt(). By implementing this function, one can control the background color of each cell of the table component using scripting. A component's extension functions can be accessed by right-clicking on the component and clicking on Scripting.

 

Extension functions allow you in a loose sense to create a custom "sub-class" of the base component type, from an object-oriented point of view. Your sub-class can then override/implement parts of the functionality of the component itself, in python. This is a very powerful, if somewhat advanced, way of configuring the component. Each component extension function comes with its own documentation built-into the function's default implementation using a standard Python "doc-string". Note that you are cannot edit the function's signature or docstring. You can only add code starting on the line after the end of the docstring.

 

Following Python object-oriented methodology, you'll notice that each extension function's first argument is called "self". That is because these are methods belong to the component's class itself. That is, they are instance methods. The value of self will always be the component itself. Notice that this is different than component event handler scripts. In those scripts, you are given an event object in your scope. The component that fired the event will be under event.source. When you write an extension function, there is no event object. The component is given to you as the self object instead.