Event-driven Programming - Event Handlers - Creating Event Handlers


Creating Event Handlers

The first step in developing an event-driven program is to write a series of subroutines, or methods, called event-handler routines. These routines handle the events to which the main program will respond. For example, a single left-button mouse-click on a command button in a GUI program may trigger a routine that will open another window, save data to a database or exit the application. Many modern day programming environments provide the programmer with event templates so that the programmer only needs to supply the event code.

The second step is to bind event handlers to events so that the correct function is called when the event takes place. Graphical editors combine the first two steps: double-click on a button, and the editor creates an (empty) event handler associated with the user clicking the button and opens a text window so you can edit the event handler.

The third step in developing an event-driven program is to write the main loop. This is a function that checks for the occurrence of events, and then calls the matching event handler to process it. Most event-driven programming environments already provide this main loop, so it need not be specifically provided by the application programmer. RPG, an early programming language from IBM, whose 1960s design concept was similar to event driven programming discussed above, provided a built-in main I/O loop (known as the "program cycle") where the calculations responded in accordance to 'indicators' (flags) that were set earlier in the cycle.

Read more about this topic:  Event-driven Programming, Event Handlers

Other articles related to "event, events":

Satanic Verses - Authenticity of The Event
... The event is considered to be weak, by the standards of Hadith authentication ... is because of the problems with the chain of narrators of the events ... says the following, with regards to the event ...
2006 Asian Games
... officially known as the XV Asiad, is Asia's Olympic-style sporting event that was held in Doha, Qatar from December 1 to December 15, 2006 ... There were 46 disciplines from 39 events scheduled to be contested ... nations of the Olympic Council of Asia took part in this event ...
... Event can refer to many things such as An observable occurrence, phenomenon or an extraordinary occurrence A type of gathering A ceremony, for example, a ... In science, technology, and mathematics Event (computing), a software message indicating that something has happened, such as a keystroke or mouse ... Event, Particle accelerator, experiments which produce high energy (Electron volt
2009 World Championships In Athletics - Organisation - Media and Marketing
... A limited edition €10 coin was produced for the event by the German government, which was only the third occasion that they had done so for a sporting event ... The colour scheme of the event, including the official logo, advertising, and the Olympiastadion's track and field, was blue and green ... The committee stated that blue represented reliability while green represented the event's environmental ambitions ...

Famous quotes containing the words creating and/or event:

    If the child knows the rewards and punishments in advance and knows that his parents will stick to them, the parents can actually empathize with the child’s plight while, at the same time, creating a firm sense of structure.... Your child will sense your resolve and your empathywhether you do this with words or just a sense of warmth.
    Stanley I. Greenspan (20th century)

    The vanishing volatile froth of the present which any shadow will alter, any thought blow away, any event annihilate, is every moment converted into the Adamantine Record of the past.
    Ralph Waldo Emerson (1803–1882)