Download presentation
Presentation is loading. Please wait.
1
Event-driven programming
Nick Sims
2
A computer program A computer program is a list of instructions that the computer works through in a logical sequence. It is written using a programming language. There are many different languages, each of which has its own rules or syntax.
3
A computer program Some languages are general purpose, such as Visual Basic and C++, which means they can be used to create different kinds of applications. Some languages are specific, such as Fortran which is used for scientific applications, and Java which is used to create web content.
4
Event-Driven Programming
Most modern computer programs that people use have Graphical User Interfaces (GUIs). A GUI has icons on the computer screen and a mouse (or other device) to control a pointer that can be used to operate the computer.
5
This slide is an image of Microsoft Word 2007
This slide is an image of Microsoft Word It is an example of a modern graphical user interface. An interface is made up of objects (or controls) such as a button or a combo box. Events happen to the objects.
6
Modern GUIs like the Word 2007 interface require the use of event-driven programming.
An event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler.
7
Event Handler An event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler.
8
Event Handler An event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler (which is code). Modern operating systems like Vista and programming languages contain facilities to let programmers set up event listeners.
9
An event trigger can be almost any activity: such as:
A mouse movement, touch screen Someone pressing the enter key Or something that is changing i.e. a bank account balance changing When a printer wants data
10
Method I can play a sound I can show a picture I can use data and do a calculation I am going to handle your event! Mouse Click = Trigger I am going to send a message An event handler is what we call in programming a method that is activated when the event trigger occurs. Almost any method can serve as an event handler, such as those that play sounds, initiate data communications, or perform calculations.
11
Event-Driven Programming
Events are an important part of programming, allowing the computer to respond to requests by a user: i.e. keyboard and mouse. Events can be used for many other purposes, such as controlling burglar alarms, checking remote sensors, or checking for system events, like printers running out of paper. Events are an important part of modern computer programming. The Events area shows existing events and is used to create new events. An event consists of a condition, called an event trigger, and the name of a method, called an event handler. Whenever the event trigger occurs, the event handler is called into action. For example, you might want the sound of a splash to occur if an ice skater falls through the ice. Some events, such as causing a method to run when a key is pressed, provide user interaction for an Alice world. Events are covered in detail in Chapter 3.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.