Some HEScript scripts such as UserMain contain pre-defined events, i.e. functions which are called by the application at appropriate times.
This topic describes these events.
About the UserMain script #
The UserMain script is automatically created when a new project is started. It contains numerous global events that allow you to insert special commands.
| Event name | Description |
|---|---|
| function OnBeforeNavigate (NewURL, TargetFrame: String): Boolean; | Triggered just before the application displays an HTML page. Set Result to True to halt the operation. NewURL is the full URL to be displayed, and TargetFrame is the frame where the page is displayed (if applicable). |
| function OnRouterURL(RequestedURL, RequestedFilename, PathInfo, QueryString: String): String; | Triggered by the router engine, allowing you to reroute any URL. Further description and samples. |
| procedure OnPHPErrorMessage(ErrorMsg: String); | Triggered when the PHP runtime returns an error. ErrorMsg contains the error message. |
| procedure OnNavigateComplete (URL: String); | Triggered when a page has finished loading. URL is the full URL of the loaded page. |
| procedure OnDownloadComplete(FullPath: String; OriginalURL: String; MimeType: String; TotalSize: Integer); | Triggered when a file download has completed. FullPath is the complete path to the downloaded file, OriginalURL is the original URL of the download, MimeType is the reported MIME type of the file, and TotalSize is the total size of the downloaded file in bytes. |
| function OnPubLoaded: Boolean; | Triggered when the application starts, before the homepage is displayed. Set Result to True to exit immediately without warning. |
| procedure OnPubBeingClosed; | Triggered when the application is about to terminate. |
| procedure OnDisplayWindow (WindowName: String); | Triggered when a window (whose name is specified by WindowName) is displayed. This applies to both main and secondary windows, such as pop-ups. |
| procedure OnStartMainWindow; | Triggered just before the main window is displayed (i.e., before the homepage is shown). |
| procedure OnCloseWindow (WindowName: String); | Triggered when a window is closed by the user. |
| function OnWindowCloseQuery (WindowName: String): Boolean; | Triggered when a user attempts to close a window. Set Result to False to prevent the window from closing, or True to allow it. This event is not created by default; you must manually add it to your project’s UserMain script to utilize it. |
| function OnTimer (TimerName: String): Boolean; | This event is triggered by a timer created using the StartTimer HEScript function. It occurs when the specified duration, set by StartTimer, has elapsed. Set the function’s Result to True to disable the timer, or use the StopTimer function. |
| procedure OnPrintPage; | Triggered when the user prints the current page. |
| function OnInvalidPasswordAtStartup: Boolean; | Triggered when an invalid global password is provided at startup. Note: Set Result to True to prevent the application from displaying an error message and exiting. |
| function OnExpiredPublication: Boolean; | Triggered when the global expiration date is reached. Note: Set Result to True to prevent the application from displaying an error message and exiting. |
| procedure OnTrayIconClick; | Triggered when the user clicks the tray icon. |
| procedure OnTrayIconDblClick; | Triggered when the user double-clicks the tray icon. |