Plugin samples

Creating side panels (dock panels)

This plugin demonstrates creating a side panel that contains a button.

var panel1;
var mainForm;

function OnReady() {
    panel1.ReDock(); //if loading layouts eliminated this panel, the redock will restore it
                     //this is important on the 1st run of the plugin
}

function OnExit() {
  //this is always a good idea with forms
  delete mainForm;
}

function ShowDock1(Sender) {
    panel1.Show();
}

function HideDock1(Sender) {
    panel1.Close();
}

function OnButtonClick(Sender) {
    Script.Message("Button was clicked");
}

//create these on script initialization so that their position can be loaded from layouts if previously saved there
panel1 = new TDockPanel("DockTest_Panel1", "dockPanelFileExplorer");
panel1.Caption = "Test Script Panel";

//create some form to show in the dock
mainForm = new TForm(WeBuilder);
mainForm.parent = panel1;
mainForm.BorderStyle = bsNone;
mainForm.Align = alClient;
mainForm.Visible = true;

var btnOk = new TButton(mainForm);
btnOK.Parent = mainForm;
btnOk.SetBounds(Round(12 * Script.DpiScale), Round(12 * Script.DpiScale), Round(80 * Script.DpiScale), Round(36 * Script.DpiScale));
btnOk.Caption = "OK";
btnOk.OnClick = &OnButtonClick;

//docks need to be re-docked on "ready" signal
Script.ConnectSignal("ready", &OnReady);
Script.ConnectSignal("exit", &OnExit);

//some test actions for toggling docks
Script.RegisterAction("Test", "Show Dock 1", "", &ShowDock1);
Script.RegisterAction("Test", "Hide Dock 1", "", &HideDock1);