For advanced users, DAQFactory exposes several system events. Most of these are somewhat advanced, and misuse can result in DAQFactory crashing, or other problems. Fortunately, the crash or other problem will probably occur immediately, so as long as you save often you should be OK even if you are not familiar with Windows event handling.
To create code that runs when the event occurs, simply create a sequence in the Local connection with the event name. Because most of these events run in the primary thread of DAQFactory, it is very important that your code be fast. Otherwise, the system will become sluggish, possibly even hanging DAQFactory. This is especially important for the OnMouseMove event, which is called around 50 times a second. The exception is probably the OnShutDown event as shut down is slow anyway. For many of the events, you can avoid the default DAQFactory processing of the event by putting return(1) at the end of the sequence code.
OnAlert(): called when an alert occurs. An alert is anything that would appear in the Command / Alert window as an alert. This does not include errors that are caught in code using try/catch. The private variable strAlert is passed into the event which is the exact text of the alert as it appears in the Command / Alert window, but without the timestamp.
Note: Since ? statements trigger this event, it is important that you do not do a ? statement inside the event or you will get an repetitive loop. Fortunately, unlike other such loops, this one is somewhat slow and so doesn't hang DAQFactory. If you make the mistake and see your message repeated over and over again, simply fix the script and Apply the changes and it should stop.
OnHelp(): called when the user presses the F1 key invoking help or when you select Help-Help Topics. Windows often captures the F1 key before it calls OnChar() or OnKeyUp(), so this is a way to use the F1 key for another purpose. To avoid displaying the DAQFactory help, put return(1) at the end of the sequence to indicate that default handling should not occur.
OnShutDown(): called when DAQFactory exits, or when a document is closed. Because of where this occurs in the Windows event structure, you cannot perform any windows based tasks here. For example, you cannot display a message box. You can, however, do things like adjust outputs and other similar clean up. Any returned value is ignored. There is no way to stop the shut down procedure.
The following events only apply when the page view is displayed and in focus. For applications running in Runtime mode, this is pretty much all the time.
OnChar(Char, Shift, Ctrl): called when the a key is pressed. The differences between this and the OnKeyUp() event are subtle. The OnKeyUp() event won't detect a repeated character when a key is held down, but it will better detect special keys like function keys. The Char parameter is the numeric key code generated; Shift is 1 if the shift key is down; Ctrl is 1 if the control key is down. Returning 1 from this event will cause DAQFactory character events to be skipped. Note that which events DAQFactory does with OnChar and which with OnKeyUp are not documented because they may change at any point. If you want to process all keystrokes, make sure and put return(1) at the end of both the OnChar() and OnKeyUp() events.
OnContextMenu(Loc, Shift, Ctrl): called when the context menu is triggered. Typically, unless the user has reassigned their mouse buttons, this is when the user right clicks. It also occurs when the popup button is pressed on newer keyboards. The Loc parameter is an array with two columns containing the current X and Y position of the mouse. Shift is 1 if the Shift key is pressed; Ctrl is 1 if the control key is pressed. Returning 1 from this event will cause DAQFactory processing of this event to be skipped.
OnKeyDown(Key, Shift, Ctrl): called when a key is pressed. The Key parameter is the keyboard scan code for the key; Shift is 1 if the shift key is down; Ctrl is 1 if the control key is down. Most of the normal keys match their ASCII equivalent. For other keys, you can search the internet for Windows key codes, or simply create an event that sets a global variable to Key, display that global variable in the watch, and simply try different keys. Returning 1 from this event will cause DAQFactory processing of this event to be skipped.
OnKeyUp(Key, Shift, Ctrl): called when a key is released. Everything else is identical to OnKeyDown()
OnLButtonDblClk(Loc, Shift, Ctrl): called when the left mouse button is double clicked. What constitutes a double click is determined by windows. The Loc parameter is an array with two columns containing the X and Y position of the mouse. Shift is 1 if the Shift key is pressed; Ctrl is 1 if the control key is pressed. Returning 1 from this event will cause DAQFactory processing of this event to be skipped.
OnLButtonDown(Loc, Shift, Ctrl): called when the left mouse button is pressed. The Loc parameter is an array with two columns containing the X and Y position of the mouse. Shift is 1 if the Shift key is pressed; Ctrl is 1 if the control key is pressed. Returning 1 from this event will cause DAQFactory processing of this event to be skipped.
OnLButtonUp(Loc, Shift, Ctrl): called when the left mouse button is released. The Loc parameter is an array with two columns containing the X and Y position of the mouse. Shift is 1 if the Shift key is pressed; Ctrl is 1 if the control key is pressed. Returning 1 from this event will cause DAQFactory processing of this event to be skipped.
OnMouseMove(Loc): called when the mouse moves on a page. The Loc parameter is an array with two columns containing the current X and Y position of the mouse. Returning 1 from this event will cause DAQFactory processing of this event to be skipped. It will not, however, cause Windows handling of this event to be skipped.
OnMouseWheel(Loc, Delta): called when the mouse wheel is moved while on a page. The Loc parameter is an array with two columns containing the current X and Y position of the mouse. Delta is typically either -120 or +120 depending on which direction the wheel is spun. Some mice with finer wheels may return smaller values. This event is typically triggered for each click of the wheel, but again, with finer wheels, the event may be triggered more often. Returning 1 from this event will cause DAQFactory processing of this event to be skipped. It will not, however, cause Windows handling of this event to be skipped.
OnRButtonDblClk(Loc, Shift, Ctrl):
OnRButtonDown(Loc, Shift, Ctrl):
OnRButtonUp(Loc, Shift, Ctrl): these three events are identical to their LButton counterparts except they apply to the right mouse button.