Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Working with touch and gesture events


When working with user interfaces that demand a high level of user interaction or certain processes to be run at certain moments, we need to consider using events and detecting them to execute methods. In this recipe, we will create some functionality that will demonstrate not only the setting of an event but also its removal.

How to do it...

We will use the methods available in the XUI library to control the delegation of event handlers:

  1. Firstly, create a new PhoneGap project named touch by running the following line:

    phonegap create touch com.myapp.touch touch
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:

    cordova platform add ios
    cordova platform add android
    
  3. Add the dialog plugin by running this line:

    cordova plugin add org.apache.cordova.dialogs
    
  4. Open www/index.html and clean up the unnecessary elements. Include a reference to the XUI JavaScript library and the Cordova JavaScript file.

  5. Add an empty script tag block before the closing...