Gestures API
From iRidium Mobile Wiki
Contents
DOWNLOAD: Example of a project
IR.AddRecognizer
This function is used for gesture activating.
Syntax:
IR.AddRecognizer(Gesture_Type);
IR.AddListener(IR.EVENT_START,0,function() // Event is activated at the application launch { IR.AddRecognizer(IR.GESTURE_SWIPE_LEFT); // Activate gesture SWIPE_LEFT IR.AddRecognizer(IR.GESTURE_SWIPE_RIGHT); // Activate gesture SWIPE_RIGHT IR.AddRecognizer(IR.GESTURE_SWIPE_UP); // Activate gesture SWIPE_UP IR.AddRecognizer(IR.GESTURE_SWIPE_DOWN); // Activate gesture SWIPE_DOWN });
IR.RemoveRecognizer
This function is used for gesture deactivating.
Syntax: IR.RemoveRecognizer(Gesture_Type);
IR.AddListener(IR.EVENT_EXIT,0,function() // Event is activated when exiting the application { IR.RemoveRecognizer(IR.GESTURE_SWIPE_LEFT); // Deactivate gesture SWIPE_LEFT IR.RemoveRecognizer(IR.GESTURE_SWIPE_RIGHT); // Deactivate gesture SWIPE_RIGHT IR.RemoveRecognizer(IR.GESTURE_SWIPE_UP); // Deactivate gesture SWIPE_UP IR.RemoveRecognizer(IR.GESTURE_SWIPE_DOWN); // Deactivate gesture SWIPE_DOWN });
IR.EVENT_GESTURE_BEGIN
Event is activated when beginning a gesture.
Syntax: IR.AddListener(IR.EVENT_GESTURE_BEGIN, Page_Name, function(gesture, x, y){Function_Body});
- gesture - the variable stores the gesture type;
- x - the variable stores x-coordinate of gesture beginning;
- y - the variable stores y-coordinate of gesture beginning;
var button; IR.AddListener(IR.EVENT_START, 0, function() // Event is activated at the application launch { // Create a button for switching pages var button = IR.CreateItem(IR.ITEM_BUTTON, "text", 10, 10); button.Text = ""; // Activating gestures IR.AddRecognizer(IR.GESTURE_SWIPE_LEFT); // Activate gesture SWIPE_LEFT IR.AddRecognizer(IR.GESTURE_SWIPE_RIGHT); // Activate gesture SWIPE_RIGHT IR.AddRecognizer(IR.GESTURE_SWIPE_UP); // Activate gesture SWIPE_UP IR.AddRecognizer(IR.GESTURE_SWIPE_DOWN); // Activate gesture SWIPE_DOWN // Connect Listener, send the current page and the function with parameters. IR.AddListener(IR.EVENT_GESTURE_BEGIN, IR.CurrentPage, function(gesture, x, y) { // Choice structure switch(gesture) { case IR.GESTURE_SWIPE_LEFT: button.Text = "Left"; // If you begin a gesture SWIPE_LEFT you see the sign "Left" break; case IR.GESTURE_SWIPE_RIGHT: button.Text = "Right"; // If you begin a gesture SWIPE_RIGHT you see the sign "Right" break; case IR.GESTURE_SWIPE_UP: button.Text = "Up"; // If you begin a gesture SWIPE_UP you see the sign "Up" break; case IR.GESTURE_SWIPE_DOWN: button.Text = "Down"; // If you begin a gesture SWIPE_DOWN you see the sign "Down" break; } }); });