Skip to content

Latest commit

 

History

History
73 lines (58 loc) · 2.25 KB

File metadata and controls

73 lines (58 loc) · 2.25 KB
sidebar_position 4

WindowClass

A <WindowClass> in skin.xml binds a FrameworkService controller to a non-blocking workspace window. WindowClass panels exist only for the current session. Restart is required after any change to the script files.

How It Connects

  1. classfactory.xml — declares the script as category="FrameworkService" (see classfactory.xml).
  2. skin/skin.xml<WindowClass controller="Name"> — references the registered controller name and binds a <Form> as the window content.
  3. scriptname.jsHost.Objects.registerObject(this, "Name") — registers the controller as a named host object in initialize().

classfactory.xml

<ScriptClass
    classID="{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"
    category="FrameworkService"
    name="My Window Service"
    sourceFile="scriptname.js"
    functionName="createInstance"/>

skin.xml

<WindowClasses>
    <WindowClass name="MyPanel"
        title="My Panel"
        controller="MyControllerName"
        form.name="MyForm"
        command.category="MyCategory" command.name="My Panel"/>
</WindowClasses>
<Forms>
    <Form name="MyForm">
    </Form>
</Forms>
  • The command.category and command.name attributes on <WindowClass> register it as a command in Studio Pro. It can be assigned in the Keyboard Shortcuts menu or launched via Find Command (Ctrl/Cmd + K).
  • The controller attribute must match the string passed to Host.Objects.registerObject().
  • See Skin Reference - WindowClass for all attributes.

scriptname.js

function MyController()
{
    this.interfaces = [
        Host.Interfaces.IComponent  // Required for controller lifecycle
    ]

    this.initialize = function(ctx)
    {
        Host.Objects.registerObject(this, "MyControllerName")  // Must match controller="..." in WindowClass
    }

    this.terminate = function()
    {
        try { Host.Objects.unregisterObject("MyControllerName") } catch(e) {}
    }
}

// Function name matches classfactory.xml functionName
function createInstance() {
    return new MyController()
}

Example

See Marker Creator for a full working example.