SlideShare a Scribd company logo
Unit 14 – Event Driven
    Programming

     What is event driven
       programming?



                            1
Key Features of EDP
1. Forms & Controls
2. Trigger functions
3. Event handlers
4. Event loops




                             2
Forms and Controls
A GUI (graphical user interface) is what the user
sees when the program runs and usually consists
of one or several forms
Each form contains various controls which
allow the user to interact with the program in
different ways e.g. Textboxes, Menus, Buttons
Each type of control has its own events e.g. a
Form events include:
   Load (open for first time, set default values)
   KeyDown (when the user presses a key)

                                                    3
Load Form




            4
Trigger functions
Event driven programs respond to events triggered
by the user via the mouse or keyboard
Common user events include clicking the mouse,
pressing a key, changing text
Different controls have different events (events for
a text box not the same for a button)
The programmer chooses which event(s) to respond
to by selecting the appropriate trigger function.



                                                       5
Button Events
Event driven programs respond to events triggered
by the user
Every object has a
range of trigger
functions – one for
each possible event
  A Button has a Click
  event, a GotFocus
  event, a MouseHover
  event etc


                                                    6
Event Handlers
An event triggers the appropriate event handler
Event handlers contain the code that runs when an
event occurs
These event handlers are self-contained sections of
code – also called Procedures or Subroutines
  VB.NET uses Sub /End Sub to start and end the code




This allows the programmer to work on one event
of one control at a time and makes testing easier
                                                       7
Event Loops
Programmers not normally aware of these
The Event loop keeps testing the user interface to
see if anything has happened (e.g. clicking on a
button or pressing a key)
When detected, the event is passed to the trigger
function which then finds the appropriate event
handler to run the code written for this purpose
Other (non user) activities can also cause an event
to trigger – typically used in networking and when
reading from or writing to files
                                                      8
Event Loop
1   User interacts with page       2   An ‘event’ is triggered


                                            EVENT!




4   The page’s appearance is       3   A code handler runs in response
    updated/modified as a result




                                                                         9
Advantages
Flexibility:
  Wide choice of controls and trigger functions
Suitability for GUI:
  uses WIMP system (Windows, Icons, Menus, Pointers)
Simplicity and Ease of development:
  Add and code one control at a time, allows a
  programmer to build up their program gradually with
  simple building blocks




                                                        10
Flexibility
Wide choice of controls – can be dragged and
dropped onto form
Good choice of trigger functions – programmer
can decide what will happen when
Programmer can assist user with intuitive
interface, restrict input to a limited range, provide
visual feedback and context-sensitive help




                                                        11
Suitable for GUIs
Are particularly suitable for event driven
programming - uses WIMP system
  Windows, Icons, Menus, Pointers
They have many objects which the programmer
can use to provide the user with alternative ways
to interact with the program (mouse or keyboard)
Most controls are independent – so code can be
naturally modular



                                                    12
Simplicity and Ease of Development

Event-driven languages such as C#, VB.NET and Visual
C++ allow a programmer to build up their program
gradually with simple building blocks
Programmers can add and code one object at a time, using
simple constructs
   Pre-written code and drop-down lists showing choice of
   possible commands
   Errors are highlighted and step through debugging
Code modules can be re-used or imported from libraries,
built-in wizards can be used
Online and local help files are readily available


                                                            13
Disadvantages
Errors can be more difficult to spot than with
simpler, procedural programs
Programs with complex GUIs may be slower to
load and run than simpler programs – particularly
if RAM is insufficient
Programs with too many forms can be very
confusing and/or frustrating for the user



                                                    14
Which control would a programmer
            use to….?
Allow a Yes/ No answer only?
Allow a wide range of keyboard input?
Limit user input to the numbers 1, 2, 3 & 4?
Allow a user to subtly change the colour or
brightness selected in a graphics application
Allow a user to access commands without
the mouse, but using keyboard navigation
only?

                                                15

More Related Content

PPTX
Presentation on Core java
PPTX
Introduction to CSS
PPTX
Graphical User Interface (GUI)
PPTX
Lecture 1 introduction to vb.net
PPTX
PHP Basics
PDF
XML and Related Technologies - Web Technologies (1019888BNR)
PPTX
La historia de linux
PDF
Php array
Presentation on Core java
Introduction to CSS
Graphical User Interface (GUI)
Lecture 1 introduction to vb.net
PHP Basics
XML and Related Technologies - Web Technologies (1019888BNR)
La historia de linux
Php array

What's hot (20)

PPTX
Php intro
PPTX
Html and Xhtml
PPTX
Android styles and themes
PPT
Android application structure
PPT
Linux file system
PPTX
Htaccess crash course for Beginners
PPTX
Android share preferences
PPTX
Constructor ppt
PPTX
Visual Basic Controls ppt
PPT
PHP - Introduction to Object Oriented Programming with PHP
PDF
Functions and modules in python
PPTX
Online Book Reading and Virtual Library Management System
PPTX
Object Oriented Programing JAVA presentaion
PDF
Visual Basic 6.0
PPTX
Java Programming
PPT
Software tools
PDF
PPTX
Presentation LIBRARY MANAGEMENT SYSTEM
PPT
Introduction to BOOTSTRAP
Php intro
Html and Xhtml
Android styles and themes
Android application structure
Linux file system
Htaccess crash course for Beginners
Android share preferences
Constructor ppt
Visual Basic Controls ppt
PHP - Introduction to Object Oriented Programming with PHP
Functions and modules in python
Online Book Reading and Virtual Library Management System
Object Oriented Programing JAVA presentaion
Visual Basic 6.0
Java Programming
Software tools
Presentation LIBRARY MANAGEMENT SYSTEM
Introduction to BOOTSTRAP
Ad

Viewers also liked (20)

PPT
Event+driven+programming key+features
PPTX
Event driven programming amazeballs
DOCX
Event oriented programming
PPTX
Event driven theory
PDF
Delphi L01 Intro
PPTX
TechDays 2010 Portugal - Event Driven Architectures - 16x9
PPTX
Service oriented programming with jolie part1
PPTX
Importance of the quality of code
PPT
Regulace v sektoru elektronických komunikací
PPTX
Nurses then & now assign. 5 technology
PPTX
Power point 5
PPTX
Iconography of music videos
PPTX
Decisions
PPTX
Data types vbnet
PPTX
Simple debugging
PPTX
Design for edp
PPTX
Software development lifecycle
PPT
Ch 3 event driven programming
PPTX
Data structures vb
PPTX
Ndu06 typesof language
Event+driven+programming key+features
Event driven programming amazeballs
Event oriented programming
Event driven theory
Delphi L01 Intro
TechDays 2010 Portugal - Event Driven Architectures - 16x9
Service oriented programming with jolie part1
Importance of the quality of code
Regulace v sektoru elektronických komunikací
Nurses then & now assign. 5 technology
Power point 5
Iconography of music videos
Decisions
Data types vbnet
Simple debugging
Design for edp
Software development lifecycle
Ch 3 event driven programming
Data structures vb
Ndu06 typesof language
Ad

Similar to Event driventheory (20)

PPTX
Controls
PPS
Vp all slides
PPT
5809566 programming concepts in vasters
PPT
cse581_03_EventProgramming.ppt
PPT
Chapter 01: Intro to VB2010 Programming
PPTX
Unit-1.pptx
PPTX
Object Oriented Programming I
PPTX
Interaction
DOC
Visual basic
PDF
Ch02 bronson
DOC
Practicalfileofvb workshop
PPTX
Forms 6i guide
PDF
GUI.pdf
PPTX
Visual studio Toolkits
PPS
01 gui 01
PDF
Introduction to Visual Basic 6.0
PPTX
Event handling in Java(part 1)
PPTX
Controls events
PDF
Ppt on visual basics
PPTX
01 Database Management (re-uploaded)
Controls
Vp all slides
5809566 programming concepts in vasters
cse581_03_EventProgramming.ppt
Chapter 01: Intro to VB2010 Programming
Unit-1.pptx
Object Oriented Programming I
Interaction
Visual basic
Ch02 bronson
Practicalfileofvb workshop
Forms 6i guide
GUI.pdf
Visual studio Toolkits
01 gui 01
Introduction to Visual Basic 6.0
Event handling in Java(part 1)
Controls events
Ppt on visual basics
01 Database Management (re-uploaded)

More from nicky_walters (14)

PPTX
Design documentation
PPTX
Pseudocode flowcharts
PPT
Algorithms
PPTX
Data types vbnet
PPTX
Data types vbnet
PPTX
Ndu06 typesof language
PPTX
Simple debugging
PPTX
Debugging
PPTX
Using loops
PPTX
Input output
PPTX
Decisions
PPTX
Decisions
PPTX
Intro to visual studio 2008
PPTX
Input output
Design documentation
Pseudocode flowcharts
Algorithms
Data types vbnet
Data types vbnet
Ndu06 typesof language
Simple debugging
Debugging
Using loops
Input output
Decisions
Decisions
Intro to visual studio 2008
Input output

Event driventheory

  • 1. Unit 14 – Event Driven Programming What is event driven programming? 1
  • 2. Key Features of EDP 1. Forms & Controls 2. Trigger functions 3. Event handlers 4. Event loops 2
  • 3. Forms and Controls A GUI (graphical user interface) is what the user sees when the program runs and usually consists of one or several forms Each form contains various controls which allow the user to interact with the program in different ways e.g. Textboxes, Menus, Buttons Each type of control has its own events e.g. a Form events include: Load (open for first time, set default values) KeyDown (when the user presses a key) 3
  • 5. Trigger functions Event driven programs respond to events triggered by the user via the mouse or keyboard Common user events include clicking the mouse, pressing a key, changing text Different controls have different events (events for a text box not the same for a button) The programmer chooses which event(s) to respond to by selecting the appropriate trigger function. 5
  • 6. Button Events Event driven programs respond to events triggered by the user Every object has a range of trigger functions – one for each possible event A Button has a Click event, a GotFocus event, a MouseHover event etc 6
  • 7. Event Handlers An event triggers the appropriate event handler Event handlers contain the code that runs when an event occurs These event handlers are self-contained sections of code – also called Procedures or Subroutines VB.NET uses Sub /End Sub to start and end the code This allows the programmer to work on one event of one control at a time and makes testing easier 7
  • 8. Event Loops Programmers not normally aware of these The Event loop keeps testing the user interface to see if anything has happened (e.g. clicking on a button or pressing a key) When detected, the event is passed to the trigger function which then finds the appropriate event handler to run the code written for this purpose Other (non user) activities can also cause an event to trigger – typically used in networking and when reading from or writing to files 8
  • 9. Event Loop 1 User interacts with page 2 An ‘event’ is triggered EVENT! 4 The page’s appearance is 3 A code handler runs in response updated/modified as a result 9
  • 10. Advantages Flexibility: Wide choice of controls and trigger functions Suitability for GUI: uses WIMP system (Windows, Icons, Menus, Pointers) Simplicity and Ease of development: Add and code one control at a time, allows a programmer to build up their program gradually with simple building blocks 10
  • 11. Flexibility Wide choice of controls – can be dragged and dropped onto form Good choice of trigger functions – programmer can decide what will happen when Programmer can assist user with intuitive interface, restrict input to a limited range, provide visual feedback and context-sensitive help 11
  • 12. Suitable for GUIs Are particularly suitable for event driven programming - uses WIMP system Windows, Icons, Menus, Pointers They have many objects which the programmer can use to provide the user with alternative ways to interact with the program (mouse or keyboard) Most controls are independent – so code can be naturally modular 12
  • 13. Simplicity and Ease of Development Event-driven languages such as C#, VB.NET and Visual C++ allow a programmer to build up their program gradually with simple building blocks Programmers can add and code one object at a time, using simple constructs Pre-written code and drop-down lists showing choice of possible commands Errors are highlighted and step through debugging Code modules can be re-used or imported from libraries, built-in wizards can be used Online and local help files are readily available 13
  • 14. Disadvantages Errors can be more difficult to spot than with simpler, procedural programs Programs with complex GUIs may be slower to load and run than simpler programs – particularly if RAM is insufficient Programs with too many forms can be very confusing and/or frustrating for the user 14
  • 15. Which control would a programmer use to….? Allow a Yes/ No answer only? Allow a wide range of keyboard input? Limit user input to the numbers 1, 2, 3 & 4? Allow a user to subtly change the colour or brightness selected in a graphics application Allow a user to access commands without the mouse, but using keyboard navigation only? 15