Actions
If needed, you can define special Actions to be taken each time your publication starts, shuts down, is activated or deactivated, changes pages or after a period of inactivity. These actions can be used to access files, play animation or music, display messages, calculate scores, verify input, etc.
The Action page contains a large editor window and a tool bar. Action commands may be typed directly into the editor, but most authors prefer to use the Insert Action button instead. Clicking the Insert Action button will display a list of available commands. The commands are organized into groups. Locate and click the title of the command you want. For most commands, VisualNEO Win will display a simple form that can be filled in to complete the Action. See Understanding Actions and Variables and Action Command Reference for a complete discussion of the Action Editor and Action Commands.
Use the tabs below the editor window to switch between the different actions. If you do not have a need for a particular Action, leave it blank. The different actions are described below:
StartUp: Actions placed here execute when your publication is first launched. This is a good place to put any initialization code or functions your publication requires.
ShutDown: These actions will execute just before your publication closes. The ShutDown Action often is used to save any publication settings or information entered by readers that you want to retain for future use. Optionally, you can abort the shutdown by changing the value of the global [ShutdownStatus] variable. For example:
MessageBox "MyPub" "Want to quit?" "Yes|No" "[Result]"
If "[Result]" "=" "2"
SetVar "[ShutdownStatus]" "Don’t do it!"
EndIf
In addition to [ShutdownStatus], you can also examine the global [ShutdownSource] variable to determine what triggered the publication to close. [ShutdownSource] may contain one of the following:
NeoBook |
The shutdown request was triggered by VisualNEO Win's Exit action. |
Windows |
The shutdown request originated with Windows. There are several Windows functions that could trigger a shutdown request, including: selecting "Turn off computer" from the Start Menu; the Task Manager's End Task command; or manually closing the application's icon from the System Tray. You should not normally refuse to close the publication when the requested to by Windows. |
CloseButton |
The user clicked on the publication window's close button, selected close from the system menu, or pressed Alt+F4. |
For example, to minimize the publication instead of closing it when the source of the shutdown is the close button, do the following:
If "[ShutdownSource]" "=" "CloseButton"
SetVar "[ShutdownStatus]" "False"
SetVar "[WindowState]" "Minimized"
EndIf
Note: It’s certainly possible with this feature to create a publication that cannot be closed, so use it with caution. The words surrounded by square brackets are variables.
Activate: These actions are executed each time your publication window becomes active, such as after using another program and switching back to VisualNEO Win.
Deactivate: Actions placed here are executed when your publication window becomes inactive, such as when the reader switches to another running program.
Page Change: These actions are executed whenever the reader attempts to navigate to another page. Optionally, the page change can be redirected or canceled by altering the value of the global [PageChangeName] variable. To redirect the reader to a different page, insert the new page’s title into the variable. For example:
SetVar "[PageChangeName]" "ErrorPage"
You can also cancel the page change by setting the variable to any empty title. For example:
If "[PageChangeName]" "=" "Goodies"
If "[User]" "<>" "Register User"
AlertBox "Sorry" "Only registered users can view that page."
SetVar "[PageChangeName]" ""
EndIf
EndIf
Idle Event: These actions are executed if no keyboard or mouse activity has been detected during the time interval specified. Enter the time interval (in seconds) that the system must remain idle before the Action is triggered.
For a kiosk publication, you could use the Idle Event to automatically return to a main page after a specified period of inactivity. This would prevent new visitors from becoming confused by a presentation left open in the middle by a previous reader. For example:
GotoPage "Start"
Subroutines: You can think of this as a repository for often used groups of actions. Instead of typing the same commands in multiple places, you can enter them once here and then reference them using the GoSub Action. Command blocks, or subroutines, begin with a unique descriptive label and end with the special command “Return”. For example:
:SubroutineOne
AlertBox "Hello" "This is my subroutine"
Return
:OtherSubroutine
AlertBox "Hello" "This is my other subroutine."
Return
Unlike the other actions in this section, subroutines are not executed automatically in response to some specific event. Instead, subroutines must be executed explicitly with the GoSub Action. For example, to execute “SubroutineOne” above, we would execute the following Action somewhere else:
GoSub "SubroutineOne"
Resized: Actions placed here are executed when the reader manually changes the width or height of your publication's main window. Under most circumstances, the Resized action should execute only once at the end of the resizing process. The Resized action can only be used when the publication's Window Style is set to the “Standard” option.