01-06-2012 03:33 AM
I'm writting an app that support both touch and trackball navigation.
so i'm using setFocus(elementId) where ever needed and it is working fine on touch emulators
but my client is using
BlackBerry 9530 Smartphone (3G, CDMA) V4.7.0.148 (Platform 4.0.0.181) BlackBerry 9530. V4.7.0.148 upgraded to v5.0.0.328
where ever i'm calling setFocus() app stops working
so is there any way to check if the mobile support touch so that i can do something similar to this
if(isTouchEnabled){
setFocus(elementId);
}
Solved! Go to Solution.
01-06-2012 04:23 AM
i solved it myself
read somewhere that resolutions are different for both touch and trackball enabled devices
so i used wikipedia and prepared list of all the resolutions of devices that support only touch
the list is as follows
"360x480",
"480x640",
"480x800",
"640x480"
using this data i wrote a javascript as follows
//--- List of all resolutions that support touch ---
var touchSupportedResolutionList = [
"360x480",
"480x640",
"480x800",
"640x480"
];
// return true if the device is touch enabled else false
function isTouchEnabled(){
var height = screen.height;
var width = screen.width;
var resolution = screen.width+"x"+screen.height;
for(var i=0 ; i<touchSupportedResolutionList.length ; i++){
if(touchSupportedResolutionList[i] == resolution)
return true;
}
return false;
}