Describe what an event is, and how events and graphical user interfaces (GUI) are related
Resources : http://xahlee.org/js/events.html
In Graphical User Interface (GUI) programming, there's the concept of event. For example, moving the mouse, clicking a mouse button, switching to a different window, hitting a key. The software needs to respond to these things. The way it works is this: The programmer writes code that draw buttons, menus, windows etc. The programmer write his program so that it knows the mouse position, mouse click, keyboard press, or any other signal from input devices. The programmer also writes code so that for example if a mouse click happened, and its position is inside a button, then some function is called as a reaction.
User interaction, such as moving the mouse, clicking a mouse button, or pressing a keyboard key cause events to occur that are handled by mechanisms implemented within the GUI system.
An event is a specific method of notification that includes its type along with a set of primary attributes. For example, when a mouse button is pressed, we need to know which button was pressed, that it went "down" and also "up", where the mouse was pointing when it did so, and any special modifiers, such as the shift or control keys, that were being held down at the time.
An event handler is software that processes an event when it occurs and makes the necessary changes to the state of GUI objects. For example, if the mouse button is clicked while the mouse was over a button image, then the handler will cause the logic of the button to operate, including its end result (reaction).
All this is very tedious and very complex. What happens today is that most of the common tasks for GUI software are already written as library, often called widget toolkit or API framework. That is to say, the codes to draw GUI elements such as windows or buttons or dialogue popups, and the detection of input signals such as...