Monday, March 28, 2011

Getting Sencha Touch to work on Non Touch Blackberry 6 Devices

Recently I decided to begin researching the current batch of options for cross-platform mobile development with a primary target device being the Blackberry Bold.
The good news is the phone runs a WebKit browser, the bad news is that the phone still sucks. Nonetheless, without much digging a seemingly wonderful framework was brought to my attention from a company I'm familiar with, Sencha, the company behind the Ext-GWT framework.
Sencha Touch is probably the most powerful HTML5 mobile frameworks out today. However with all its greatness it has one shortcoming: Though they state they have Blackberry 6 support,  they really only support one Blackberry 6 device, the Torch.

So what happens when you try to access an app built using Sencha Touch on a non-touch Blackberry? It renders well but you can't click anything, making the app just eye candy.

Alas, there is a quick and dirty solution to it.

NOTE: There are two versions of Sencha Touch, the open source (GPLv3) and the paid commercial license. This solution involves modifying the Sencha Touch source. I only show it as a demonstration, use it as-is. 

Sencha Touch provides a wrapper for mouse & touch events to support gestures, dragging and touching. This modification involves making Sencha think of the Blackberry as if it were a standalone browser in terms of input. This may not be the best/only/right solution but it's a start. 

I looked at the sencha-touch-debug.js file since its detailed and I could understand what was going on. 

The three changes that need to be made are:
Line 4763:
Touch: ('ontouchstart' in window) && (! && !,

Line 13964:
if (!Ext.desktop && !Ext.Blackberry) {...}

Line 18217:
if ( || {...}

There you have it.

Hopefully future versions of Sencha Touch will implement support for non-touch Blackberry 6 devices through a much better way than my hack.