Before you configure events for the Event structure to handle, review the caveats and recommendations for using events in LabVIEW.
Complete the following steps to configure an Event structure case to handle an event.
- (Optional) If you want to configure the Event structure to handle a user event, a Boolean control within a radio buttons control, or a user interface event that is generated based on a reference to an application, VI, or control, you first must dynamically register that event.
- Right-click the border of the Event structure and select Edit Events Handled by This Case from the shortcut menu to display the Edit Events dialog box to edit the current case. You also can select Add Event Case from the shortcut menu to create a new case.
- Specify an event source in the Event Sources pane.
- Select the event you want to configure for the event source, such as Key Down, Timeout, or Value Change, from the Events list. When you select a dynamic event source from the Event Sources list, the Events list displays that event. This is the same event you selected when you registered the event. If you registered for events dynamically and wired event reg refnum out to the dynamic event terminal, the sources appear in the Dynamic section.
- If you want to add additional events for the current case to handle, click the blue plus button and repeat steps 3 and 4 to specify each additional event. The Event Specifiers section at the top of the dialog box lists all the events for the case to handle. When you click an item in this list, the Event Sources section updates to highlight the event source you selected. You can repeat steps 3 and 4 to redefine each event or click the red X button to remove the selected event.
- Click the OK button to save the configuration and close the dialog box. The event cases you configured appear as selection options in the event selector label at the top of the event structure and the Event Data node displays the data common to all events handled in that case.
- (Optional) You can use a Timeout event to configure an Event Structure to wait a specified amount of time for an event to occur. Wire a value to the Timeout terminal at the top left of the Event structure to specify the number of milliseconds the Event structure should wait for an event to occur before generating a Timeout event. The default value for the Timeout terminal is –1, which specifies to wait indefinitely for an event to occur.
- Repeat steps 1 through 6 for each event case you want to configure.
Refer to the following VIs for examples of using events:
- labview\examples\Dialog and User Interface\Events\Events.lvproj
- labview\examples\Structures\Event Structure\Event Structure.lvproj