Event CS Thinking Example 1

Follow the full solution, then compare it with the other examples linked below.

Example 1

easy
In a GUI application, a user clicks a 'Submit' button. Describe what happens in terms of events and event handling.

Solution

  1. 1
    Step 1: The click generates an event — a signal that something has happened (a 'click event' on the Submit button).
  2. 2
    Step 2: The operating system detects the click and passes the event to the application.
  3. 3
    Step 3: The application has an event handler (a function) linked to the Submit button's click event. This handler runs — for example, it might validate the form and send the data.

Answer

The click creates an event, which triggers an event handler function that processes the form submission.
Event-driven programming revolves around responding to events (user actions, timers, messages). Instead of running linearly, the program waits for events and runs the appropriate handler.

About Event

A detectable action or occurrence in a program—such as a user click, key press, mouse movement, or timer expiry—that the program can respond to by executing a predefined event handler function.

Learn more about Event →

More Event Examples