EventScript (Object)

Member of:

EventScripts collection

Description:

Provides read and write access to all event handling scripts provided for all shapes, documents and Dashboard sections with event handlers.

The EventScript object has three properties: Name, Script, and Type, and no methods. The Name property is a read-only string containing the event name for example, “OnClick”.

The Script property is a read/write string containing the event handler’s JavaScript source code, as it is seen in the script editing dialog.

The Name property allows the object tree to display the EventScript objects with their event names and provides named access by way of the Item method.

The Type property allows for better performance when checking event types if this is required.

Constants:

The Type property of the EventsScripts (Collection) is a read-only value of the enumeration BqScriptableEvents, which consists of the following values:

Example:

This example shows how to create a command button named “cbcreated” on an OnClick event. It also writes the results of the script to the Console Window:

Console.Writeln("Start Dynamically Add CommandButton")

Console.Writeln("Step1")
var oCBShape = ActiveDocument.Sections["Dashboard"].Shapes.CreateShape(bqButton)

Console.Writeln("Step2")
oCBShape.Name = "CBCreated"
oCBShape.Text = "CBCreated"
oCBShape.Visible = true
oCBShape.Enabled = true
oCBShape.Locked = false
//Font color not enable for CommandButtons
//oCBShape.Font.Color = bqBlue
oCBShape.Font.Effect = bqFontEffectUnderline
oCBShape.Font.Name = "Ariel"
oCBShape.Font.Size = "12"
oCBShape.Font.Style = bqFontStyleItalic

Console.Writeln("Step3")

Console.Writeln("Width: " + oCBShape.Placement.Width)
Console.Writeln("Height: " + oCBShape.Placement.Height)

oCBShape.Placement.Modify(25, 25, oCBShape.Placement.Width, oCBShape.Placement.Height)

Console.Writeln("Step4")

if (Application.Type != bqAppTypeThinClient)
{
oCBShape.EventScripts["OnClick"].Script = 'Console.Writeln("OnClick")'
oCBShape.EventScripts["OnClientClick"].Script = 'Console.Writeln("OnClientClick")'
}
else
{
oCBShape.EventScripts["OnClick"].Script = 'Console.Writeln("OnClick")'

oCBShape.EventScripts["OnClientClick"].Script = 'alert("OnClientClick")'
}

Console.Writeln("Step5")

oCBShape.OnClick()
oCBShape.OnClientClick()

Console.Writeln("End Add CommandButton")

Properties:

Read only: Name as String. Type as BqScriptableEvents

Read-write: Script as String

Methods:

None