Getting custom linear gestures to work

I am able to enable the predefined gestures and even a custom hold, but for the life of me I cannot get a custom linear gesture to work. I think it may be the startX, startY, endX, endY coordinates but anything I try does not seem to work.

function enableGesture()

{

//register for event

gesture.detected = 'onGesture(%json)';

// Register for a Swipe left-right

gesture.type = 'linear';

gesture.preset = 'left-right';

gesture.create();

gesture.type = 'linear';

gesture.preset = 'top-bottom';

gesture.create();

gesture.type = 'linear';

gesture.id = 'swipe-top';

gesture.startX = 300;

gesture.starty = 60;

gesture.endX = 60;

gesture.endY = 60;

gesture.create();

gesture.type='hold';

gesture.centerX=60;

gesture.centerY=60;

gesture.id="press";

gesture.create();

document.getElementById('gLog').innerHTML = "Gesture Enabled";

}

function onGesture(gObj)

{

    document.getElementById('gLog').innerHTML += "<BR/>" + gObj.id;

}

In the code above I am expecting a swipe from the right to the left at the top portion of the screen (which is 480x640). All events work except the swipe-top. What am I doing wrong? I am using build 1.0.0.10

Sara Ashington
Hi DarrynYes it somewhat did.

Hi Darryn

Yes it somewhat did. I was able to get a custom gesture for  top of screen but could not get a diagonal from upper left to bottom right to work:

Works:

gesture.type = 'linear';

gesture.id = 'swipe-top';

gesture.startX = screen.width * .10;

gesture.startY = screen.height * .30;

gesture.endX = screen.width * .80;

gesture.endY = screen.height * .30;

Doesn't work:

gesture.type = 'linear';

gesture.id = 'swipe-diag';

gesture.startX = screen.width * .10;

gesture.startY = screen.height * .30;

gesture.endX = screen.width * .80;

gesture.endY = screen.height * .80;

How do you use the diagnostics? I turned it on using gesture.diagnostics=true but did not see anything different.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
That should work, are you

That should work, are you setting diagnostics to true before you create the gesture?  You have to set it true for every gesture.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
Looks like you have a case

Looks like you have a case-sensitive problem.

gesture.starty = 60;

should be

gesture.startY = 60;

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
Hi Sara,Did this solve your

Hi Sara,

Did this solve your problem?  If not you may also find the diagnostics features of gestures helpful.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Sara Ashington
That did the trick. I did not

That did the trick. I did not realize I had to enable it per gesture. Doing it before the gesture.create() enabled the viewing of the gesture rectangles. What do the numbers next to the green line mean?

Screen01.jpg

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Sara Ashington
Guess I should read the help

Guess I should read the help file. The first number shown is the skew and the second is the deviation. Very helpful. Thanks.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments