Charles Petzold www.charlespetzold.com Touch Input.

Slides:



Advertisements
Similar presentations
Understanding an Apps Architecture ASFA Computer Science: Principles Fall 2013.
Advertisements

Understanding Mobile App Development Concepts and Working with APIs Lesson 6.
(Multi)? Touch with Windows Phone Ben Dewey Tallan, Inc.
Event Handling. Overview How to listen (and not listen) for events Creating a utility library (and why you should) Typology of events Pairing event listeners.
Software Usability Course notes for CSI University of Ottawa Section 6: Thoughts on Mobile and Multi-Touch Usability Timothy C. Lethbridge
Charles Petzold Silverlight for Windows Phone.
Other Input Methods Pre-Lab Lecture 4 1. Revisit 2  Pre-Lab 3 – Animation  Boundary Information  Layer Concept  Animation algorithm  Next Position.
Touches Detection and Other Remaining Parts Lecture 3 1.
The Science of Digital Media Microsoft Surface 7May Metropolia University of Applied Sciences Display Technologies Seminar.
IPad Pilot 35 Pilot Schools JB Kelly Thurgood Marshall All schools will receive an Admin iPad for the Teacher the rest will go to non-verbal students,
Sketchify Tutorial Graphics and Animation in Sketchify sketchify.sf.net Željko Obrenović
Silverlight Development Win Phone 7 Mohammed M. Melhem Senior ICT Assistant: Application Silverlight and Win Phone.
Extending your with Windows 7 and Surface WPF features Katrien De Graeve Developer Evangelist Microsoft Belgium & Luxembourg
Windows 7 Building a Multi-Touch Enabled Point of Sales System.
User Interface Programming in C#: Direct Manipulation Chris North CS 3724: HCI.
Charles Petzold Navigation.
Electrical and Computer Engineer Large Portable Projected Peripheral Touchscreen Team Jackson Brian Gosselin Jr. Greg Langlois Nick Jacek Dmitry Kovalenkov.
WCL208. Slate Mobile Slate Mobile Laptop Portable Laptop Portable Displays TV, Monitor Displays TV, Monitor All-in-One Desktop All-in-One Desktop.
Exploring the Basics of Windows 8
What Silverlight Developers Must Know to Build Great Mobile Apps Jeff Prosise
1 TouchDevelop Chapter 8-10 Presenter: Jing Xu. 2 Outline Interactions Game Board Tiles and Printing.
 Brad Carpenter General Manager Surface Platform PC17.
Introduction to Mobile Programming. Slide 2 Overview Fundamentally, it all works the same way You get the SDK for the device (Droid, Windows, Apple) You.
An Introduction to Silverlight Matt Harrington Developer Evangelist, Microsoft October 20, 2011.
COMPUTER PROGRAMMING I Objective 8.03 Apply Animation and Graphic Methods in a Windows Form (4%)
(C) 2010 Pearson Education, Inc. All rights reserved. Omer Boyaci.
manipulation events. ManipulationStarting and ManipulationStarted. ManipulationDelta. ManipulationCompleted combine info from multiple events IsManipulationEnabled=true.
QML Qt Quick with QML and you can use JavaScript for engine along C++ Started to be released since late 2009 (Qt 4.7) Nokia focused on that for the Symbian/Meego.
Code for touch, get mouse and pen for free Pointer API captures pen motion, passing coordinates to Ink API Ink API helps render and stores motion.
Timer, Animation Responding to Mouse & Keyboard Lab 7 7 McGraw-Hill© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
For iOS Double-click your iPad’s home button to reveal the open apps. 2. Swipe left or right, tap an icon or a thumbnail to instantly switch to.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
Build advanced touch apps in Windows 8
Ronnie Saurenmann Microsoft Switzerland
CIS 3.5 Lecture 2.2 More programming with "Processing"
App Theming & PVL Direct3DDirectWriteDirect2DMediaTouch.
Where Value and Innovation Co-exist Gestures and User Interaction Best Practices.
Windows 10 UWP MVVM In Depth
Silverlight 101 Ahead! If you know Silverlight and are looking for more advanced content check out : ‘Microsoft Silverlight “Media” : Moving at 60fps’
Electrical and Computer Engineer Large Portable Projected Peripheral Touchscreen Team Jackson Brian Gosselin Jr. Greg Langlois Nick Jacek Dmitry Kovalenkov.
Building Windows Phone Applications with Silverlight Jaime Rodriguez
Virtual techdays INDIA │ 9-11 February 2011 Developing Windows 7 based Multi-Touch Application Ujjwal Kumar │ Partner technical consultant, Microsoft.
CPSC 481 – Week #7 Sowmya Somanath
An Introduction to Developing Applications for Microsoft Silverlight Jaime Rodriguez
 2002 Prentice Hall. All rights reserved. 1 Outline Mouse Event Handling Keyboard Event Handling Graphical User Interface Concepts:
Integral Users will interact with your app on a big screen with keyboard and mouse.
Model View ViewModel Architecture. MVVM Architecture components.
Events. Slide 2©SoftMoore Consulting Events Events are generated when a user interacts with the view objects of an application. Examples –button clicked–
CS320n –Visual Programming Execution Control with If / Else and Boolean Functions (Slides 6-2-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
JQuery Events, Mobile Events, and Page Events CIS 136 Building Mobile Apps 1.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Understanding Mobile Devices, Interactions, and Tools Lesson 1.
4.5. Respond to the touch interface 4.6. Code additional HTML5 APIs 4.7. Access device and operating system resources JavaScript Coding for the Touch Interface,
04 | Code by Using JavaScript Christopher Harrison | Content Developer, Microsoft Rachel Jones| Microsoft Certified Trainer, SourceDev.
CHAPTER 7 TouchGestures. Chapter objectives: To code the detection of and response to touch gestures. Patterns of common touches to create touch gestures.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
Multitouch and Gestures in Ubuntu Ubuntu Hardware Summit 2010 Presentation by Chase Douglas
Touch and Go: Leading Touch UI with Open Source
AnDroid GoogleMaps API
Introduction to Event-Driven Programming
Objectives To define terminology associated with Windows operating systems. To examine uses of Windows in business and industry. To explain techniques.
Objectives To review concepts covered in the Windows Operating Systems units.
Lesson 1: Buttons and Events – 12/18
Mobile Computing With Android ACST 4550 Android Logs and Gestures
Make great Metro style apps that are touch-optimized using HTML5
Program and Graphical User Interface Design
Graphics And Animation
The Implementation of a Glove-Based User Interface
More programming with "Processing"
Direct Manipulation.
Presentation transcript:

Charles Petzold Touch Input

Agenda Mouse events Frame.TouchReported events Manipulation events GestureListener events

Primary touch events promoted to mouse events –MouseLeftButtonDown, MouseLeftButtonUp, MouseMove, MouseEnter, MouseLeave –"Primary" means first finger down Build touch interfaces using mouse logic only –Same code works in Silverlight desktop apps Single-touch only! Mouse Events

Responding to Touch // XAML <Rectangle Width="300" Height="200" Fill="Red" MouseLeftButtonDown="OnRectangleClicked" /> // C# void OnRectangleClicked(object sender, RoutedEventArgs e) { (sender as Rectangle).Fill = new SolidColorBrush(Colors.Blue); }

demo Mouse Events

Low-level touch events fired by Silverlight –Up to four fingers at a time –Fired at application level, not by individual objects Information regarding individual fingers conveyed in TouchPoint objects revealing: –Whether finger went down, moved, or lifted up –Finger position relative to specified UI element –Contact area size –Topmost element underneath finger and finger ID Primary touch points promoted to mouse events Touch.FrameReported Events

Handling Touch.FrameReported Touch.FrameReported += OnFrameReported;. void OnFrameReported(object sender, TouchFrameEventArgs e) { // TODO: Act on touch input }

TouchFrameEventArgs Class MethodDescription GetPrimaryTouchPoint Returns a TouchPoint object representing primary touch point (first finger to contact screen) GetTouchPoints Returns a TouchPointCollection containing one TouchPoint object for each finger currently in contact with the screen SuspendMousePromotion- UntilTouchUp Suspends promotion of primary touch events to mouse events until all fingers have left the screen PropertyDescription Timestamp Time at which event occurred, expressed as ticks (milliseconds)

TouchPoint Class PropertyDescription Action Indicates whether a finger touched the screen (Down), moved across the screen (Move), or left the screen (Up) Position Location of the touch event in pixel coordinates relative to the upper-left corner of the object passed to GetPrimaryTouchPoint or GetTouchPoints Size Width and height (in pixels) of the touch point TouchDevice Returns a reference to a TouchDevice object representing the finger that precipitated the touch event. Use TouchDevice's Id property to identify the finger, or its DirectlyOver property to identify the topmost object under the touch point

Responding to Touch // XAML // C# Touch.FrameReported += OnFrameReported;... void OnFrameReported(object sender, TouchFrameEventArgs e) { // Single touch only TouchPoint point = e.GetPrimaryTouchPoint(null); if (point.Action == TouchAction.Down && point.TouchDevice.DirectlyOver == Rect) { Rect.Fill = new SolidColorBrush(Colors.Blue); }

Responding to Multi-Touch // XAML // C# Touch.FrameReported += OnFrameReported;... void OnFrameReported(object sender, TouchFrameEventArgs e) { TouchPointCollection points = e.GetTouchPoints(null); foreach (TouchPoint point in points) { if (point.Action == TouchAction.Down && point.TouchDevice.DirectlyOver == Rect) Rect.Fill = new SolidColorBrush(Colors.Blue); }

demo Touch.FrameReported Events

High-level touch events fired by UI elements –Do not support simultaneous manipulation –Perform implicit capture when element is moved Built-in inertia support –Velocity info in ManipulationCompleted events –You provide logic to use the velocity info Consolidate interaction of two fingers into X and Y scaling factors for pinch-zooming Manipulation Events

EventDescription ManipulationStarted Fired when a manipulation begins ManipulationDelta Fired when a finger moves during a manipulation ManipulationCompleted Fired when a manipulation ends

Moving a UI Element // XAML // C# private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e) { Rectangle rect = sender as Rectangle; TranslateTransform transform = rect.RenderTransform as TranslateTransform; transform.TranslateX += e.DeltaManipulation.Translation.X; transform.TranslateY += e.DeltaManipulation.Translation.Y; }

Scaling a UI Element // XAML // C# private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e) { if (e.DeltaManipulation.Scale.X > 0.0 && e.DeltaManipulation.Scale.Y > 0.0) { Rectangle rect = sender as Rectangle; ScaleTransform transform = rect.RenderTransform as ScaleTransform; transform.ScaleX *= e.DeltaManipulation.Scale.X; transform.ScaleY *= e.DeltaManipulation.Scale.Y; }

ManipulationCompletedEventArgs properties expose velocity information –IsInertial – True if finger was moving when it left the screen, false if not –FinalVelocities.LinearVelocity.X –FinalVelocities.LinearVelocity.Y –FinalVelocities.ExpansionVelocity.X –FinalVelocities.ExpansionVelocity.Y Use these properties to simulate inertia –e.g., start animation to continue motion Inertia

Simulating Horizontal Inertia private void OnManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { if (e.IsInertial) { Rectangle rect = sender as Rectangle; TranslateTransform transform = rect.RenderTransform as TranslateTransform; InertiaAnimation.To = transform.X + e.FinalVelocities.LinearVelocity.X / 10.0; InertiaStoryboard.Begin(); }

demo Manipulation Events

Three ways to support gestures –Roll your own using Touch.FrameReported events –Use the XNA Framework's TouchPanel class –Use the Silverlight for Windows Phone Toolkit's GestureListener class GestureListener makes it easy –Event-based API recognizes six basic gestures –No simultaneous manipulation of UI elements –Microsoft.Phone.Controls.Toolkit assembly Gestures

Gesture Types GestureListener supports six gestures –Tap –Double tap –Tap and hold –Drag or pan –Flick –Pinch Pinch gestures can be used for scaling, rotation, or both

GestureListener Events EventDescription Tap Indicates that a UI element has been tapped DoubleTap Indicates that a UI element has been double-tapped Hold Indicates that a tap-and-hold has occurred over a UI element Flick Indicates that a UI element has been flicked DragStarted Indicates that a drag gesture has started DragDelta Indicates that a drag gesture is ongoing DragCompleted Indicates that a drag gesture has ended GestureStarted Indicates that a gesture has begun (fired at beginning of every gesture) GestureCompleted Indicates that a gesture has ended (fired at end of every gesture) PinchStarted Indicates that a pinch gesture has started PinchDelta Indicates that a pinch gesture is ongoing PinchCompleted Indicates that a pinch gesture has ended

Responding to Taps // XAML // C# private void OnTap(object sender, GestureEventArgs e) { (sender as Rectangle).Fill = new SolidColorBrush(Colors.Blue); } GestureBegin Tap GestureCompleted GestureBegin Tap GestureCompleted

Responding to Double Taps // XAML // C# private void OnDoubleTap(object sender, GestureEventArgs e) { (sender as Rectangle).Fill = new SolidColorBrush(Colors.Blue); } GestureBegin Tap GestureCompleted GestureBegin DoubleTap GestureCompleted GestureBegin Tap GestureCompleted GestureBegin DoubleTap GestureCompleted

Responding to Holds // XAML // C# private void OnHold(object sender, GestureEventArgs e) { (sender as Rectangle).Fill = new SolidColorBrush(Colors.Blue); } GestureBegin Hold GestureCompleted GestureBegin Hold GestureCompleted

Moving a UI Element // XAML // C# private void OnDragDelta(object sender, DragDeltaGestureEventArgs e) { Rectangle rect = sender as Rectangle; TranslateTransform transform = rect.RenderTransform as TranslateTransform; transform.X += e.HorizontalChange; transform.Y += e.VerticalChange; } GestureBegin DragStarted DragDelta... DragDelta DragCompleted GestureCompleted GestureBegin DragStarted DragDelta... DragDelta DragCompleted GestureCompleted

Responding to Flicks // XAML // C# private void OnFlick(object sender, FlickEventArgs e) { Rectangle rect = sender as Rectangle; TranslateTransform transform = rect.RenderTransform as TranslateTransform; InertiaAnimation.To = transform.X + e.HorizontalVelocity / 10.0; InertiaStoryboard.Begin(); } GestureBegin DragStarted DragDelta... Flick DragCompleted GestureCompleted GestureBegin DragStarted DragDelta... Flick DragCompleted GestureCompleted

Scaling a UI Element // XAML // C# private void PinchDelta(object sender, PinchGestureEventArgs e) { Rectangle rect = sender as Rectangle; ScaleTransform transform = rect.RenderTransform as ScaleTransform; transform.ScaleX = _cx * e.DistanceRatio; transform.ScaleY = _cy * e.DistanceRatio; } GestureBegin PinchStarted PinchDelta... PinchDelta PinchCompleted GestureCompleted GestureBegin PinchStarted PinchDelta... PinchDelta PinchCompleted GestureCompleted

Rotating a UI Element // XAML // C# private void PinchDelta(object sender, PinchGestureEventArgs e) { Rectangle rect = sender as Rectangle; RotateTransform transform = rect.RenderTransform as RotateTransform; transform.Rotation = e.TotalAngleDelta; } GestureBegin PinchStarted PinchDelta... PinchDelta PinchCompleted GestureCompleted GestureBegin PinchStarted PinchDelta... PinchDelta PinchCompleted GestureCompleted

demo GestureListener Events

Charles Petzold Questions?