Script Form¶
Script Form is a opinionated, TLazForm
that you can setup and run in
a just a few lines.

A very basic TScriptForm
with 3 tabs¶
This page is only about the very base of TScriptForm
.
For information about pre-built panels you can find them on these pages:
TScriptForm¶
Main type for the TScriptForm.
Built-in Callbacks¶
TScriptForm has several built-in callbacks setup by default:
ScriptForm.OnClose¶
procedure TScriptForm.OnClose(sender: TLazObject; var closeAction: ELazFormCloseAction);
Callback called when the TScriptForm.Form.OnClose
procedure.
This ensures the script is terminated when you close the form.
Closing the form programatically with ScriptForm.Form.Close()
will also
terminate your script by default if you don’t want this you will need to do
something similar to what ScriptForm.OnStart which does the following
when it runs:
ScriptForm.Form.OnClose := nil;
ScriptForm.Form.Close();
ScriptForm.OnStart¶
procedure TScriptForm.OnStart(sender: TLazObject);
This callback is ran on the TScriptForm.Start.OnClick
procedure.
By default, it’s only used to close/hide the form and ensure that
ScriptForm.OnClose doesn’t run.
The recommended usage for scripts would be to override this to setup your script
variables when it runs before calling inherited
, something like this:
Example:
procedure TScriptForm.StartScript(sender: TLazObject); override;
begin
CurrentTask := ETask(Self.TaskSelector.GetItemIndex());
inherited;
end;
ScriptForm.Setup¶
procedure TScriptForm.Setup(caption: String = 'Script Form'; size: TPoint = [750, 500]; allowResize: Boolean = False);
Responsible for setting your TScriptForm up. This sets up the sekeleton of your TScriptForm ready to take in tabs.
ScriptForm.CreateTab¶
function TScriptForm.CreateTab(caption: String): TLazTabSheet;
Methods to create and add tabs to TScriptForm
.
This will create a new tab on the form and return it to you as the result so you add controls to it.
Example:
{$I WaspLib/osrs.simba}
var
form: TScriptForm;
selector: TCombobox;
tab: TLazTabSheet;
begin
form.Setup();
tab := form.CreateTab('House');
selector := TLazComboBox.CreateEx(tab);
form.Run();
end.
ScriptForm.AddTab¶
procedure TScriptForm.AddTab(owner: Pointer);
Adds an already existing TLazTabSheet
to the TScriptForm
.
ScriptForm.Run¶
procedure TScriptForm.Run();
Runs and shows your TScriptForm
after it has been setup.