Script

The Script object is one of the two global script objects provided by Opus. This** **object is provided to script addins when their various event handlers are invoked (other than for the OnInit event). It provides information relating to the script itself.

Property NameReturn TypeDescription

config

Returns a ScriptConfig object representing the configuration values for this script. In the OnInit method a script can define the properties that make up its configuration - the user can then edit these values in Preferences. The object returned by the config property represents the values that the user has chosen.

file

string

Returns the path and filename of this script.

vars

object:Vars

Returns a Vars object that represents the variables that are scoped to this particular script. This allows scripts to use variables that persist from one invocation of the script to another.

Method Name

Arguments

Return Type

Description

InitColumns

none

none

If your script implements the OnAddColumns event, you can call the InitColumns method at any time to reinitialize your columns. You may want to do this, for example, in response to the user modifying your script's configuration.

InitCommands

none

none

If your script implements the OnAddCommands event, you can call the InitCommands method at any time to reinitialize your commands. You may want to do this, for example, in response to the user modifying your script's configuration.

LoadImage

<string:name> [<int:width>] [<int:height>] [<bool:alpha>]

object:Image

Loads an image file from the specified external file. If your script is bundled as a script package you can place image files in a sub-directory of the package called images and then load them from your script by giving their name. You can optionally specify the desired size to load the image at, and whether the alpha channel (if any) should be loaded or not.

The returned Image object can be given as the value of the Control.label property for a static control in a script dialog (when that control is in "image" mode). You can also assign as to the icon property of a Dialog object to specify a custom window icon for your script dialog.

LoadResources

<string:name> or <string:XML>

none

Loads external script resources and makes them available to the script. You can either provide a filename or a raw XML string. If your script is bundled as a script package, the resource file must have a .odxml extension for LoadResources to be able to find it in the package.

RefreshColumn

<string:name>

none

If your script implements any custom columns, you can use this method to cause them to be regenerated if they are currently shown in any tabs. You may want to do this, for example, in response to the user modifying your script's configuration. Pass the name of the column you want to regenerate as the argument to this method.

UpdateFAYTFlags

<string:name> <int:flags>

none

Lets a script add-in update the flags for a FAYT extension. This equates to the options shown to the user for the FAYT mode on the Quick Keys Preferences page.

The name should be the name of the FAYT extension command; this is given to your command as the ScriptFAYTCommandData.fayt property. The flags value should represent a flag combination that's meaningful to your extension.

最后更新于