Jump to content

Event model

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by BMF81 (talk | contribs) at 09:45, 4 October 2005 (GUI programming paradigm). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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.

Delagate event model

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

This model is based on three entities:

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

Furtermore the model requires that:

  • every listener must implement the interface for the event it wants to listen to (done at programming time)
  • every listener must register to the source, to declare is will to listent some particular events (done at runtime)
  • everytime that the source generates an event, it comunicates it to the registered lsteners, following the protocol of the interface