KEMBAR78
Ch 3 event driven programming | PPT
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 . An Introduction to Programming Using Alice
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
Event-Driven Programming An Introduction to Programming Using Alice 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
This slide is an image of Microsoft Word 2007.  It is an example of a modern graphical user interface.
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 .
An  event  occurs whenever an  event listener  detects an  event trigger  and responds by running a method called an  event handler .
An  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.
An  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.
An  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.
Events in Alice Alice events are created in the  events area  of the standard Alice interface. events area
Events in Alice Alice events are created in the  events area  of the standard Alice interface. events area
Events in Alice 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 Alice The  create   new event  button   will reveal a menu with nine different event types. create new event  button
Events in Alice The  create   new event  button   will reveal a menu with nine different event types.
Events in Alice A programmer can pick the event type that has the desired event trigger.
Events in Alice A programmer can pick the event type that has the desired event trigger. Some event types also have built-in event handlers…
Events in Alice 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.
Event handlers are specified by dragging method tiles from the details area and dropping them into the event tile.
Event-Drive Programming 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.

Ch 3 event driven programming

  • 1.
  • 2.
    Event-Driven Programming Mostmodern 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
  • 3.
    Event-Driven Programming Mostmodern 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
  • 4.
    Event-Driven Programming AnIntroduction to Programming Using Alice 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.
    An Introduction toProgramming Using Alice
  • 6.
    This slide isan image of Microsoft Word 2007. It is an example of a modern graphical user interface.
  • 7.
    Modern GUIs likethe 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 .
  • 8.
    An event occurs whenever an event listener detects an event trigger and responds by running a method called an event handler .
  • 9.
    An 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.
  • 10.
    An eventtrigger 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.
  • 11.
    An eventhandler 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.
  • 12.
    Events in AliceAlice events are created in the events area of the standard Alice interface. events area
  • 13.
    Events in AliceAlice events are created in the events area of the standard Alice interface. events area
  • 14.
    Events in AliceAn 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.
  • 15.
    Events in AliceThe create new event button will reveal a menu with nine different event types. create new event button
  • 16.
    Events in AliceThe create new event button will reveal a menu with nine different event types.
  • 17.
    Events in AliceA programmer can pick the event type that has the desired event trigger.
  • 18.
    Events in AliceA programmer can pick the event type that has the desired event trigger. Some event types also have built-in event handlers…
  • 19.
    Events in AliceA 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.
  • 20.
    Event handlers arespecified by dragging method tiles from the details area and dropping them into the event tile.
  • 21.
    Event-Drive Programming Eventsare 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.

Editor's Notes

  • #13 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.
  • #14 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.
  • #15 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.
  • #16 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.
  • #17 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.
  • #18 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.
  • #19 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.
  • #20 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.
  • #21 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.
  • #22 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.