Each GUI is made up of standard components that any program can use. You should have noticed many of these standard components while working on your labs. Almost all buttons, text fields, menus, etc. have the same look and feel, no matter what program you find them in. This is good for two reasons: software developers no longer have to design their own buttons and such, since these are provided for them; and the users of the programs are presented a more consistent interface, since all program developers use the same graphical features now. To make an interface for their programs, designers need only choose where to put the various items such as buttons, menus, text fields, etc.
Once the interface is designed and in place, the program looks complete: menus will drop down when you click on them, buttons will look pressed when you press them. The only thing wrong is that nothing happens when you press a button, or when you select a menu item. The button knows what to look like when you press it, but you never told it what to do when you press it. To assign actions to the various features of an interface, the program needs to interpret a set of automatically generated messages called events.
When you click on a button, the button generates an event, then sends the event to a routine called the event handler. In a typical programming language, an event looks something like this:
EVENT( <sender>, <nature of event>)where the sender is a specific button, menu item, or text field, and the nature of the event can be such things as "mouse passed over me", "someone pressed me", or "someone changed the text inside of me". For example, when you click on the "OK" button in a window, an event is generated that looks something like this:
EVENT(OK_BUTTON, Someone Pressed Me)The events are sent to an event handler which performs the task associated with that event, such as telling other components to do something, or performing some calculations. As an example, when you attempt to exit a program without saving an altered file, a window will pop up asking you if you want to save the file:
EventHandler (EVENT E) // E is the event to handle IF (the sender of event E is YES_BUTTON and the event is BUTTON_PRESS) Save the file and tell the program to exit IF (the sender of event E is NO_BUTTON and the event is BUTTON_PRESS) Tell the program to exit(Don't save the file) IF (the sender of event E is CANCEL_BUTTON and the event is BUTTON_PRESS) Tell the pop-up window to remove itself from the screen and let the program continue to run IF (the event is none of the above pass the event to someone else to deal with, or ignore it)
PREVIOUS | 1 | 2 | 3 | 4 | 5 | 6 | 7 | NEXT |