Event-driven programming is a programming pattern in which you create diagram code that executes outside the dataflow structure as a result of an event occurring.
Use event-driven programming when you want diagram code to execute in response to an event. An event is anything that happens to the user interface or diagram during run time that provides a notification to other parts of a program.
Events are handled by the Event Structure. The Event Structure waits for events, responds to those events, then returns to waiting for the next event. Place your code in a subdiagram of the Event Structure, which handles the event you specify and executes the code.
For example, if you want an event to occur when the user presses a specific key on the panel, you can design an application to include a loop that waits until the key press event occurs, handles the event, and returns to wait for the next event. While the loop waits for the event to occur, other parts of the application can continue to run. How the application handles each event depends on the code written for that specific event. Some sections of the program may execute frequently because the events those sections handle occur frequently, and other sections of the program may not execute at all because the events never occur.