Event driven programming
Download
1 / 36

Event-driven programming - PowerPoint PPT Presentation


  • 612 Views
  • Updated On :

Event-driven programming. 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 .

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Event-driven programming' - bob


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Event driven programming2 l.jpg
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.


Event driven programming3 l.jpg
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.

An Introduction to Programming Using Alice


Slide4 l.jpg

This slide is an image of Microsoft Word 2007. It is an example of a modern graphical user interface.


Slide5 l.jpg

Modern GUIs like the Word 2007 interface require the use of example of a modern graphical user interface.event-driven programming.

An event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler.


Slide6 l.jpg

An example of a modern graphical user interface.event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler.


Slide7 l.jpg

An example of a modern graphical user interface.event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler.

Modern operating systems and programming languages contain facilities to let programmers set up event listeners.


Slide8 l.jpg

An example of a modern graphical user interface.event trigger can be almost any activity or condition selected by the programmer, such as a mouse movement, someone pressing the enter key, or a bank account balance changing.


Slide9 l.jpg

An example of a modern graphical user interface.event handler is 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.


In alice l.jpg
In Alice… example of a modern graphical user interface.

  • Events can be used to control objects moving in 3D space.

    • Detect when some object moves

    • Detect when two objects collide

    • Make objects move in response to mouse or keyboard commands.

  • So before discussing events in Alice, let’s talk about 3D space a little more.


3d space l.jpg
3D space example of a modern graphical user interface.

  • A dimension is a way of measuring something.

  • We create a dimension whenever we assign a value on a continuous scale to some property.

  • Example: On a scale of 1 to 100, how much do you approve of George Bush’s performance as president?


Measuring distance l.jpg
Measuring distance example of a modern graphical user interface.

  • If you wish to measure the location of a point on a straight line, then you only need one number.

  • You could mark a start point on the line, and then measure how far a point is from the start point

  • By using negative and positive numbers, you could also indicate which direction the distance spans.


Orientation l.jpg
Orientation example of a modern graphical user interface.

  • In addition, to the concepts of distance and direction, we also have the concept of orientation.

  • Orientation means the direction the object is facing.

  • If an object is facing the positive direction on the line, its orientation is forward.

  • If facing negative, then backward.


Point of view l.jpg
Point of view example of a modern graphical user interface.

  • Location and orientation together are known as the point of view of an object.


Two ideas of direction l.jpg
Two ideas of direction example of a modern graphical user interface.

  • Absolute vs. object-relative.

  • Absolute direction of boy on bike I backward, but forward in relation to Alice


Object relative positions l.jpg
Object-relative positions example of a modern graphical user interface.

  • From the coach’s point of view, Alice is behind the boy, while the coach is in front of the boy.


Position in 2d l.jpg
Position in 2D example of a modern graphical user interface.

  • On a flat surface, like a sheet of paper, you need two values to specify an object’s position (two dimensions).

  • Rene Descarte developed a system of quantification for two dimensions.

  • This is called Cartesian coordinates.

  • Cartesian coordinates have an X axis (dimension) and Y axis.

  • The coordinates of a point are always specified as x,y.


A third dimension l.jpg
A third dimension example of a modern graphical user interface.

  • Moving up and down off a flat plane requires a third axis or dimension.

  • Instead of an ordered pair to represent position, we need an ordered triplet (x,y,z).

  • In Alice the z axis provides a measurement of depth.

  • 3D space is sometimes called Euclidean 3-space after the Greek mathematician, Euclid.


Absolute vs object relative l.jpg
Absolute vs. Object-relative example of a modern graphical user interface.

  • For all objects we must be aware of absolute position and direction

  • However, we are most commonly concerned with object-relative position and direction.


More on object relativity l.jpg
More on object-relativity example of a modern graphical user interface.

  • We must also frequently consider the movement of objects from the perspective of other objects.

  • See SharkAsSeenByExample.a2w


Events in alice l.jpg

Events in Alice example of a modern graphical user interface.


Events in alice25 l.jpg
Events in Alice example of a modern graphical user interface.

Alice events are created in the events area of the standard Alice interface.

events area


Events in alice26 l.jpg
Events in Alice example of a modern graphical user interface.

Alice events are created in the events area of the standard Alice interface.

events area


Events in alice27 l.jpg
Events in Alice example of a modern graphical user interface.

An Alice event tile specifies the event trigger and the event handler.

In this example, the event trigger is the spacebar, being pressed and the event handler is the iceSkater’s simpleSpin method.


Events in alice28 l.jpg
Events in Alice example of a modern graphical user interface.

The createnew event buttonwill reveal a menu with nine different event types.

create new event button


Events in alice29 l.jpg
Events in Alice example of a modern graphical user interface.

The createnew event buttonwill reveal a menu with nine different event types.


Events in alice30 l.jpg
Events in Alice example of a modern graphical user interface.

A programmer can pick the event type that has the desired event trigger.


Events in alice31 l.jpg
Events in Alice example of a modern graphical user interface.

A programmer can pick the event type that has the desired event trigger.

Some event types also have built-in event handlers…


Events in alice32 l.jpg
Events in Alice example of a modern graphical user interface.

A programmer can pick the event type that has the desired event trigger.

Some event types also have built-in event handlers…In other cases, programmers must specify the handler.


Slide33 l.jpg

Event handlers are specified by dragging method tiles from the details area and dropping them into the event tile.


Exploring events l.jpg
Exploring Events the details area and dropping them into the event tile.

  • Start Alice and open the amusementPark example world.

  • In the events area, you should see seven event tiles.


Amusement park events l.jpg
Amusement Park Events the details area and dropping them into the event tile.


Event driven programming36 l.jpg
Event-Driven Programming the details area and dropping them into the event tile.

  • Events are an important part of Alice programming, allowing the creation of interactive worlds with keyboard and mouse user controls.

  • Most modern programming languages allow programmers to add events to new software.

  • 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.


ad