Translate

Saturday, September 28, 2013

Double or multiple touch sensing APP INVENTOR Canvas

In this tutorial I am explaining about how to sense double touch (Multiple click) in MIT APP Inventor Canvas. 
 App Inventor is a very good and simple tool for Android development invented by google labs and now hosted in MIT server. A CANVAS is a two dimensional touch sensitive rectangular panel on which drawing can be done and sprites can be moved . With the help of CANVAS, you can make variety of applications and that palatte is capable to track your gestures on the touch screen. Unfortunately, APP inventor team (Google, MIT) not given any answer for the question, “How to sense the double or multiple touch using CANVAS ”. I have searched on many websites, But I didn’t get any response. Thus I created a block to sense app inventor double/ multiple touch action (Double Click). With the help of this tutorial you will study how you can use the timer or clock pallatte for your android development. 

LOGIC Behind this work

Sensing: How often you touched up the canvas for a short interval (~500 milli seconds=1/2 seconds).

At First you have to insert following Pallates using APP inventor designer webpage 
  •  CANVAS 
  •  CLOCK
  • TEXT BOX 
Click save and open CODE EDITOR (on a JAVA installed system)




 STEPS

 For that you need a global variable , that will store your number of clicks (Touch)
 to make a global variable
Click on Definition> Name block 
Give a suitable name . In my case I have given name “time”. 



Next You have to give a time interval for timer, for double click we need only ½ seconds only. So I have given timer value to 500 mS. I have put that block in screen initialization block (See the figure).



Canvas1.Mouse touch up will give information about how often you touched the canvas.
If you clicked multiple times , variable "timer" will increase by 1 (see math block inside Canvas1.Mousetouchup block). At the end of 1 timer cycle (500 mS). An interrupt will be fired and the entire execution cycle of the program will reach in the clock1.timer block, In that block I printed the number of clicks stored in our global variable (timer) to the TextBox1. After printing the value on text box 1, set the time variable value to zero.(Otherwise it increases with every click) 

For more information 


http://pravysoft.eu5.oorg/praveen

or email us to