There are two types of events in scripts:

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

  • OnContinue called 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.

  • OnInitialize called when the Initialize button is pressed or an initialize macro command is executed.

  • OnBeforeSave called before Viz Trio saves the current page. The script can cancel saving by returning false OnBeforeSave = false.

  • OnSave called when the Save button is pressed or a save macro command is executed.

  • OnBeforeTake called before Viz Trio runs a take on the current page. The script can cancel the take by returning false OnBeforeTake = false. Only triggered if the template or a page using the template is read.

  • OnTake called 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.

  • OnTakeOut called 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.

  • OnUpdate called when an update action is executed in Viz Trio (See keyboard shortcut list on control page).

  • OnUserClick called 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.

  • OnSocketDataReceived called 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

  • OnShowOpen called when show is opened.

  • OnShowClose called when show is closed.

  • OnRead called 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.

  • OnInitializeShow same as OnInitialize for template scripts.

  • OnCleanupRenderers called 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.

  • OnTake called when the Take button is pressed or a take macro command is executed.

  • OnTake(PageName) called when a specific page is taken.

  • OnTakeOut called 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 the PageName is 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 if
end function
 
' or the same logic in one line:
function OnDelete(PageName)
OnDelete = PageName <> "2000"
end function

Examples of commands that trigger OnDelete event:

  • Gui commands

    • gui:copy_selected_pages_to_number

    • gui:copy_selected_pages_with_offset

    • gui:move_selected_pages_to_number

    • gui:move_selected_pages_with_offset

  • Show commands

    • show:copy_pages_to_number

    • show:copy_pages_with_offset

    • show:delete_all_pages

    • show:delete_templates

    • show:move_pages_to_number

    • show:move_pages_with_offset

    • show:rename_page

  • Page commands

    • page:delete_page

    • page:delete_pagerange

See Also