Jump to content

Event model

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Erik9bot (talk | contribs) at 08:30, 14 August 2009 (add Category:Articles lacking sources (Erik9bot)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The event model is a programming paradigm commonly used in building graphical user interfaces. A very common and very programmer-friendly variant is the delegate event model, which is provided by the most popular graphic frameworks.

Delegate event model

Delegate event model. Click me is the event source (a button in this example), and it contains a list of listeners.

This model is based on three entities:

  • a control, which is the event source
  • consumers, also called listeners, that receive the events from the source
  • interfaces (in the broader meaning of the term) that describe the protocol by which every event is to be communicated

Furthermore the model requires that:

  • every listener must implement the interface for the event it wants to listen to
  • every listener must register with the source, to declare its desire to listen to some particular event
  • every time the source generates an event, it communicates it to the registered listeners, following the protocol of the interface