Reference > Script triggers reference > OnPanelSwitch
Performs a script when a panel control changes panels. This can happen in a tab control, for example, when a user clicks an inactive tab panel or when a script changes the focus to an object on a different tab panel.
When the script runs
Before the event has been processed.
Modes in which the trigger can be used
Browse and Find modes.
You can use the Exit Script script step within the triggered script to return True or False.
True: The event that triggered the script proceeds.
False: The event that triggered the script is canceled.
Where the script trigger is activated 
FileMaker Pro 
FileMaker Server 
FileMaker Go 
Custom Web Publishing 
FileMaker WebDirect 
Runtime solution 
Originated in 
FileMaker Pro 12.0
OnPanelSwitch applies to the entire panel control and not to individual panels. To control switching to particular panels, use the Get(TriggerCurrentPanel) and Get(TriggerTargetPanel) functions.
Because this trigger is activated before the panel switch event is processed, the value of the script parameter that OnPanelSwitch passes to your script is determined before the panel is switched. Therefore, if you use the script parameter to pass the returned value of Get(TriggerCurrentPanel) or Get(TriggerTargetPanel) into your script, the value will be zero. To get useful returned values, use these functions only within the script activated by OnPanelSwtich, not in the script parameter.
Related topics 
Setting up script triggers
Setting script triggers for layouts
Setting script triggers for objects