[Tutor] event-based programming

Erik Price erikprice@mac.com
Thu, 11 Jul 2002 22:43:43 -0400


I was wondering if one (or more) of the helpful geniuses on this list 
could help me understand how event-based programming works.  This is 
something that I have seen in a Java program called RoboCode and also in 
JavaScript-enabled web browsers, which trigger event handlers written in 
JavaScript embedded into an HTML documents, and I'm sure that it can be 
done with a language like Python.  But what I don't understand is how 
the program knows to "watch" for the event.

Does the event have to "target" the event handler with a message, or 
does the simple act of an "event" being triggered cause the event 
handler to execute?  In other words, does the event handler watch some 
specific code for an event to happen, or does the event have to be sent 
to the event handler?  And how does one write code that "watches" for 
events in this fashion, regardless of whether it is targetted or not -- 
does that mean that event-based code must be written like a daemon, 
constantly running and waiting for messages?

I'm hoping someone can give me a very high-level, theoretical 
explanation of how this works.


TIA,


Erik