Lab 6: event & input intro User Interface Lab: GUI Lab Oct. 2 nd, 2013.

Slides:



Advertisements
Similar presentations
Event handling and listeners What is an event? user actions and context event sources and listeners Why should my programs be event- driven? User interaction.
Advertisements

What Was I Thinking??. Key Terms 1. Control 1. Control 2. Design Mode 2. Design Mode 3. Event 3. Event 4. Form 4. Form 5. Interface 5. Interface 6. Properties.
Lab 10: Images and Skinning, Sound and Assets User Interface Lab: GUI Lab Oct. 30 th, 2013.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 1 Tariq Aziz and Kevin Jones.
1 Flash Actionscript Event Handling. 2 Event Handling Right now we know all about variables lets go back to our text input/output example: Suppose we.
Chapter Day 10. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 10 Questions from last Class?? Problem set 2 posted  10 programs from.
Kapi’olani Community College Art 258 Interface Programming II In-class Presentation Week 5A.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Chapter Day 9. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 8 Questions from last Class?? Problem set 2 posted  10 programs from.
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Getting started with Microsoft.NET Gadgeteer Comberton Village College Gadgeteer Club.
Lab 2: Interface Building User Interface Lab: GUI Lab Sep. 4 th, 2012.
KRAD makes it easy to handle HTML events in your webpage. Kuali University: Apply Now Lab 6: Fun with HTML Events Lab Objectives HTML Events – what are.
Event-driven Programming
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Lab 5: drawing and output User Interface Lab: GUI Lab Sep. 25 th, 2013.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
IE 411/511: Visual Programming for Industrial Applications
Introduction to Matlab & Data Analysis
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Event Driven Programming, The.
Getting a handle on ActionScript A basic primer for non-programmers.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
GEMVC. The Setup Folders Views Value Objects (VOs) Custom Events Service CFCs Controller Model Application Main MXML.
Lab 3: Actionscript User Interface Lab: GUI Lab Sep. 11 th, 2012.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Concurrent Programming and Threads Threads Blocking a User Interface.
Chapter 2 – Introduction to the Visual Studio .NET IDE
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
UID – Event Handling and Listeners Boriana Koleva
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Microsoft Visual Basic 2012 CHAPTER ELEVEN Multiple Classes and Inheritance.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
Creating User Interfaces Event-Driven Programming.
Creating a GUI Class An example of class design using inheritance and interfaces.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
CISC 110 Day 6 Introduction to Events. Outline Event-Driven Programming Event Classes Hierarchy –Event Class –Mouse Events –Keyboard Events Registering.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Dive Into® Visual Basic 2010 Express
Chapter 1: An Introduction to Visual Basic 2015
Visual Basic Code & No.: CS 218
Introduction to Event-Driven Programming
Chapter Topics 15.1 Graphical User Interfaces
Event-driven programming
Event loops 16-Jun-18.
Chapter 2 – Introduction to the Visual Studio .NET IDE
1. Introduction to Visual Basic
Lesson 1: Buttons and Events – 12/18
Event Driven Programming
Event loops.
Extend Text Editor to Draw shapes
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Chapter 15: GUI Applications & Event-Driven Programming
Event loops 8-Apr-19.
Tonga Institute of Higher Education
Event loops.
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Lab 6: event & input intro User Interface Lab: GUI Lab Oct. 2 nd, 2013

Lab 6 goals Hw1b review Debugging Techniques Events and Event handlers

Hw1b Maybe a little too much? Review Actionscript Syntax

Debugging Official method: trace() with Flash Player in debugging mode

Debugging Simple method: print it on the screen!

Events Flex applications are event driven – Outside of startup, every action is result of a trigger Two even types: – System events: component ready, timer done, etc. – User events: mouse clicks, keyboard presses, etc.

Event handlers The pieces of code that get run after an event occurs Think of them as spring loading your program

Event handlers Written in actionscript Takes in “event” parameter – More information about the event – Ex. position of the mouse, holding ctrl, etc.

take this mxml application… what does it look like?

take this mxml application… everything is run on startup

We want to pop up an alert when pressed…

select button -> “generate event handler” does this for you

…after generating the event handler where is the event handler here?

Event handler will get run only when button is pressed

Showing an alert when the button is pressed

Green stuffs: run when application starts Orange stuffs: run when the button is pressed

Event handlers An event handler may handle events from multiple objects. An object might distribute events to multiple event handlers.

In-class project Create a new Flex project named “Lab6ICP” Create a VGroup Put a button in Vgroup – Label: Button 1 – Id: myButton1 Put a label in Vgroup – Doesn’t have any text in it – Id: myLabel

Create a click event handler for the button Go back to source, take a look at the event handler – The parameter passed in is called “event” that has a type “MouseEvent” – What attribute does this event object have? Explore using the autocomplete menu (event. …)

Use event parameter to see if shift key is pressed when button is clicked Run and see the result

Create another button and let it use the same click event handler Put a new button in VGroup between Button 1 and the label – Label: Button 2 – Id: myButton2 Add an click event handler to the button in MXML How do I know which button is clicked?

Add a parameter to the event handler to identify which button is clicked Event handler is just a function that gets called when a specific event happens and takes that event as a parameter. It can be edited like any other functions.

Things to note Objects may have different event types – What event does a button object have?

Things to note Event -> Show inherited Events

Event handler in Lab5ICP Add an event handler to an object in actionscript Lab 5 ICP

public function myFunction(x:int):int{ return x+1; } Access control DeclarationName Return type Name & type of the parameter(s) passed in

public function myFunction(x:int):int{ return x+1; } Access control DeclarationName Return type Name & type of the parameter(s) passed in

Make your GUI_rectangle interactive Open Lab5ICP or download the solution from Blackborad Suppose we want the rectangle to change its color when the user hovers the mouse on it, and pop up an alert box when the user clicks it, what event handler should we add to the rectangle? – GUI_rectangle extends UIComponent

Make your GUI_rectangle interactive Add three event handlers in the constructor – MouseEvent.CLICK: pops up an alert saying “Click!” – MouseEvent.MOUSE_OVER: draw a gray rectangle – MouseEvent.MOUSE_OUT: draw a black rectangle

(if we have time) Review Right now the initial color and hover color are set in the class file – The blueprint already decides the color of the shape What if I want to have many rectangles in my interface, each have different colors? – Let the color becomes a public attribute that can be accessed and changed in MXML (during instantiation) – Solution on Blackboard (Lab5ICP_solution-Oct3)

Next time: more on event & input