Non-user events

The events we have seen so far have been triggered by user actions like clicking on a button or moving the mouse over or out of a region on the screen. But all events are not triggered by users. The computer can be programmed to handle many types of event. Consider, for example, this stopwatch program.

This computer checks the system clock, and every second it triggers a ClockTick event. The programmer had to write an event handler for the ClockTick event:

on ClockTick: add one to the seconds counter and display the new value.

Here is a second version of the program in which the user can specify the time between ClockTick events.

You have seen other examples of events that are not triggered by the user. For example, when you receive an instant message, the event handler displays a notification. Or, when a Web server receives a request for a particular page, the event handler retrieves that page and sends it back to the client that requested it. Computers are also embedded in cars and all sorts of appliances. When the clock on your microwave oven reaches 0, it has been programmed to turn off the cooking element and beep.

Initially we will focus on events triggered by user actions, but later we will look at others.


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.