|
|
|
| Every GUI platform, be it Microsoft Windows, Motif on Unix, or the Macintosh GUI, employs the concept of events. Different GUI platforms may use different terminology (for example, Microsoft Windows uses the term "Windows messages"), but they all use basically the same concept. Events can be things like:
Events are delivered using messages. The operating system usually has a message system which can send and receive messages containing event information. When you (or the system) sends a message, you send it to an object on the system -- a window, a control (button, edit box, list control, whatever), etc. Microsoft Windows, Mac, UNIX systems, etc. all use event-driven message sending mechanisms heavily in their windowing support. Note, however, that while events are very important in GUI programming, there are also many other applications where events are useful. Why are Events Important?Event and message delivery are a major part of how windowing systems work, and therefore the messaging system must be efficient. Objects in a windowing system typically sit around waiting to be told what to do -- if they are told to do nothing, they'll do exactly that! Therefore, you need to understand how the events and messaging system work to make things work properly, and to make things work efficiently. What are Event-Driven Systems?Anything that typically sits around waiting to be told what to do, and responding to external stimuli, is event-driven. An example of an environment which makes the event-driven nature of the system very obvious is Microsoft Visual Basic. Lots of programs have been modeled after VB, including many of the Java IDEs. The Event QueueTypically, each GUI implementation has a single first-in, first-out queue into which each generated event is placed. Events are handled serially, to avoid timing conflicts among multiple events. In the Java GUI, there is a special thread, called the Event Queue [Dispatch] Thread. Events are queued to this thread, which processes them in the order in which they were added to the queue. |
|
This page was last modified on 02 October, 2007 |