There are two types of events in scripts:
template scripts with template events
show scripts with show events
Although these events look similar, they differ.
When used in scripts, events are only called if the specific event described by the event-handler occurs.
Info: Template scripts are loaded only when a page/template is read. Some template events are triggered only if the template or a page using the template is read.
This section covers the following topics:
Template Event Callbacks
OnContinuecalled when the Continue button is pressed or a continue macro command is executed. Only triggered if the template or a page using the template is read.OnInitializecalled when the Initialize button is pressed or an initialize macro command is executed.OnBeforeSavecalled before Viz Trio saves the current page. The script can cancel saving by returning falseOnBeforeSave = false.OnSavecalled when the Save button is pressed or a save macro command is executed.OnBeforeTakecalled before Viz Trio runs a take on the current page. The script can cancel the take by returning falseOnBeforeTake = false. Only triggered if the template or a page using the template is read.OnTakecalled when the Take button is pressed or a take macro command is executed. Only triggered if the template or a page using the template is read.OnTakeOutcalled when the Take Out button is pressed or a take out macro command is executed. Only triggered if the template or a page using the template is read.OnUpdatecalled when an update action is executed in Viz Trio (See keyboard shortcut list on control page).OnUserClickcalled when the user clicks the Run macro button or when the Viz Trio macro command execute_script is executed.OnValueChanged(PropertyName,NewPropertyValue)used with template scripts. The event is called when a property in the page is changed, sending in the name of the property and the new value.OnSocketDataReceivedcalled when socket data is received on the defined port. A socket object must be configured on the configuration page.OnPropertyFocused(PropertyName)called when a tab-field editor gets focus in the Viz Trio user interface. It sends the property name into the function that uses the event.OnShowVariableChanged(Name, Value)called when a global variable is changed or added. All Viz Trio clients (including the client where this command was issued) that have the same show open, receive the event when the command show:set_variable is used.OnGlobalVariableChanged(Name, Value)called when a show variable is changed or added. All Viz Trio clients that are connected to the same Media Sequencer with the same show open, receive the event when the command trio:set_global_variable is used.
Show Event Callbacks
OnShowOpencalled when show is opened.OnShowClosecalled when show is closed.OnReadcalled when the Read button is pressed or a read macro command is executed.OnRead(PageName)called when a specific page is read.OnContinue(PageName)called when the Continue button is pressed or a continue macro command is executed.OnInitializeShowsame asOnInitializefor template scripts.OnCleanupRendererscalled when the trio:cleanup_renderers or trio:cleanup_all_channels commands are executed.OnBeforeSave(PageName)called before a specific page is saved.OnSave(PageName)called when a specific page is saved.OnBeforeTake(PageName)called before a specific page is taken.OnTakecalled when the Take button is pressed or a take macro command is executed.OnTake(PageName)called when a specific page is taken.OnTakeOutcalled when the Take Out button is pressed or a take out macro command is executed.OnTakeOut(PageName)called when a specific page is taken out.OnUpdate(PageName)called when a specific page is updated.OnValueChanged(PageName, PropertyName,NewPropertyValue)used with show scripts to specify thePageNameis called. The event is called when a property in a show’s page is changed. It sends in the name of the page, the name of the property and the new value.OnSocketDataReceived(data)called when data received on socket.OnPropertyFocused(PageName, PropertyName)called when property focused.OnCopy(OldName, NewName)called when a page is copied. The event is only available to show scripts.OnMove(OldName, NewName)called when a page is moved or renamed. The event is only available to show scripts.OnDelete(PageName)called when a page is deleted. The script can abort deletion by returning false (OnDelete = false).
Info: This event is a function, hence, it can return a value. If you set it to false, it does not delete the page in question. If you set it to anything else or do not return a value, the page in question is deleted. The event is only available to show scripts (see using the OnDelete script event).
OnShowVariableChanged(Name, Value)called when show variable changed.OnGlobalVariableChanged(Name, Value)called when global variable changed.
Note: Events with the same name but different argument values are not the same. For example OnRead() and OnRead(Pagename) are not the same event.
Using the OnDelete Script Event
For example, the following show script cancels the delete operation of any page named 2000.
function OnDelete(PageName) if PageName = "2000" then OnDelete = false else OnDelete = true end ifend function' or the same logic in one line:function OnDelete(PageName) OnDelete = PageName <> "2000"end functionExamples of commands that trigger OnDelete event:
Gui commands
gui:copy_selected_pages_to_numbergui:copy_selected_pages_with_offsetgui:move_selected_pages_to_numbergui:move_selected_pages_with_offset
Show commands
show:copy_pages_to_numbershow:copy_pages_with_offsetshow:delete_all_pagesshow:delete_templatesshow:move_pages_to_numbershow:move_pages_with_offsetshow:rename_page
Page commands
page:delete_pagepage:delete_pagerange
See Also