Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
New Developer
Posts: 20
Registered: ‎05-07-2011
My Device: Bold
My Carrier: Rogers

AIR, GWT, and OnSwipeDown

I've developed an app using Google Web Toolkit, then re-packaged into a WebWorks application using bbwp.  My problem is the inconsistent behavior of the onswipedown call.  Actually, all this code is in the HTML file, and so GWT ought not to play a part in it, but I mention it for completeness.  Here is are some code fragments, based on an article by Adam Stanley:

 

 

<script type="text/javascript">
 function onSwipeDownCallback() {
 document.getElementById("menuBar").className = "showMenuBar";
 }
 function showMenuBar() {
 document.getElementById("menuBar").className = "showMenuBar";
 }
 function hideMenuBar() {
 document.getElementById("menuBar").className = "hideMenuBar";
 }
 function showAbout() {
 alert(blackberry.app.description + "\nBy " + blackberry.app.author
 + "\nVersion " + blackberry.app.version);
 }
 function setHandlers() {
 blackberry.app.event.onSwipeDown(onSwipeDownCallback);
 }
</script>

 

 

 

The function setHandlers is called onLoad, and it registers the onSwipeDownCallback to the onSwipeDown event.  When you swipe down, the class of the menuBar is changed to showMenuBar, and the CSS (not shown here) transitions the div so that it rolls down from the top.

 

Here's the weird part.  It works some of the time.

 

If it never worked, then I'd be happily debugging.  But some of the time??  It seems to either always work or never works.  In other words, when I start the app, and the menu refuses to appear on the swipe down, then it never appears.  I close the app, and restart it.  Fails again.  I close the app, and restart it.  It works!  And it will work every time I swipe down.  I close the app, and restart it.  Stops working.

 

Another weird clue.  I get the same behavior on the simulator.  Works or doesn't work.

 

Any clues?  Anyone ever have this sort of strangeness using blackberry.app.event?

 

Here is the code from the config.xml file that refers to the API:

 

 

<content src="Viewer.html" />

 

<feature id="blackberry.ui.dialog" />

<feature id="blackberry.app" />

<feature id="blackberry.app.event" />

 

<script type="text/javascript"> function onSwipeDownCallback() { document.getElementById("menuBar").className = "showMenuBar"; } function showMenuBar() { document.getElementById("menuBar").className = "showMenuBar"; } function hideMenuBar() { document.getElementById("menuBar").className = "hideMenuBar"; } function showAbout() { alert(blackberry.app.description + "\nBy " + blackberry.app.author + "\nVersion " + blackberry.app.version); } function setHandlers() { blackberry.app.event.onSwipeDown(onSwipeDownCallback); }</script>

New Developer
Posts: 31
Registered: ‎04-21-2011
My Device: Playbook
My Carrier: N/A

Re: AIR, GWT, and OnSwipeDown

Do you have a link to the original Adam Stanley article? I'm having a different GWT-based problem and I'd like to see the article you used before I ask questions of my own.

Thanks!
New Developer
Posts: 20
Registered: ‎05-07-2011
My Device: Bold
My Carrier: Rogers