Event Driven Programming Anatomy – Handle

Slides:



Advertisements
Similar presentations
Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Advertisements

Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Introduction to Macromedia Director 8.5 – Lingo
FLUID  The Fast Light User Interface Designer, or FLUID, is a graphical editor that is used to produce FLTK source code  Creates C++ code  Compile.fl.
6/13/20151 CS 160: Lecture 13 Professor John Canny Fall 2004.
Cosc 4755 Phone programming: GUI Concepts & Threads.
Writing GUI Applications An introduction with Java.
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
Welcome to CIS 083 ! Events CIS 068.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
CSC 298 Windows Forms.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
FLTK Tutorial.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
CS350 – Windows Programming Formerly and more properly named: Event Driven Programming Dr. Randy Ribler.
Computer Science 112 Fundamentals of Programming II Command Buttons and Responding to Events.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
FLTK. Objectives Install and Use FLTK Widgets ◦Callbacks Handling event ◦System events ◦Mouse events ◦Keyboard events.
Download you-tube video. Step 1: Open Youtube Downloader Click to open Youtube Downloader.
Events (Alice In Action, Ch 6) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September 2012.
Dialog boxes in JavaScript Events in JavaScript – What are they – “Which events are there?” – “How do I register event handlers to an HTML element?” –
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Event-Driven Programming 1.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
OpenGL in FLTK  .
Implement User Input Windows Development Fundamentals LESSON 2.4A.
Procedural programming Procedural programming is where you specify the steps required. You do this by making the program in steps. Procedural programming.
NxWM Threading Model Main Thread NX Server Thread CCallback Touchscreen Listener Thread NX Event Callback Messages Mouse Events Hardware Touchscreen Events.
(More) Event handling. Input and Windowed-OS’s Windowed OS’s (Windows, OSX, GUI-linux’s) send messages (events) when the user does something “on” the.
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
Events and Event Handling
CS345 – Event-driven Programming
EE 200 Design Tools Laboratory 14
Event Loops and GUI Intro2CS – weeks
Event-driven programming
Event loops 16-Jun-18.
Event Driven Programming Dick Steflik
FLTK The Fast Light Toolkit
CSC461 Lecture 8: Input Devices
Introduction to Events
Ellen Walker Hiram College
Chapter 2: GUI API Chapter 2.
Event Driven Programming
Introduction to Computing Using Java
Exceptions with Functions
Anatomy of Polymorphism
Event loops.
Exceptions CSCE 121 J. Michael Moore
Visual programming Chapter 2: Events and Event Handling
1/10/2019 JavaFX Events COSC 330.
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Review: Applying Computer Basics
Anatomy of Inheritance
Inheritance in Graphics
Professor John Canny Spring 2004 March 5
Event loops 8-Apr-19.
Graphics and FLTK CSCE 121 J. Michael Moore
Tonga Institute of Higher Education
Anatomy of Polymorphism
Chapter 13: Handling Events
Event loops.
Professor John Canny Spring 2003 March 12
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
ACM programming contest
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Event Driven Programming Anatomy – Handle CSCE 121 J. Michael Moore Based on slides created by Carlos Soto.

Recall - Events Mouse Keyboard Touch Sensor events Messages from other threads and programs (including the OS) User-generated events. The “interactive” part of interactive programs

Events in FLTK FLTK handles mouse, keyboard, and a few other events (such as clipboard-paste and window-fullscreen) When “something happens” (like moving or clicking the mouse), FLTK generates an event For example, an event is generated when a button widget is pressed An FLTK button “knows” that it has been activated, and can “tell us” It’s up to us to decide what to do when it happens http://www.fltk.org/doc-1.3/events.html#events_model

The FLTK event loop Fl::run(); Enters the FLTK event loop waits for events (originating from the OS) handles them continues to wait for more events. Loop continues until main window is closed

Handling Order OS gets event (e.g. user event) Event is sent to our program through FLTK FLTK gives the event to a FL_Widget object (e.g. a button) The FL_Widget object handles the event

Handling events virtual int Fl_Widget::handle(int event); We override handle in our own derived classes, thus defining the event-handling behavior Never call handle() ourselves, FLTK does that for us Return 1 if the event was “handled” Return 0 if it was not (e.g. if it was not used) Call parent’s handler if we don’t define what to do (avoid “short-circuiting”)

Overriding the handle() function int MyClass::handle(int event) { switch(event) { case FL_PUSH: // handle mouse press return 1; case FL_RELEASE: // handle mouse release default: return Fl_Widget::handle(event); } http://www.fltk.org/doc-1.3/subclassing.html#subclassing_events