diff -r 913c9751c067 -r 716254ccbcc0 org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-AE9BB3E0-C243-476B-A236-40958A1DAED9.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-AE9BB3E0-C243-476B-A236-40958A1DAED9.html Fri Mar 05 19:11:15 2010 -0800 @@ -0,0 +1,40 @@ + + +Checking for touch support

Checking for touch support

The Web Runtime (WRT) API does not provide a way to detect whether a device is touch-enabled. You can use simple but error-prone heuristics to detect it.

+

The first S60 touch UI devices have bigger screen resolution than older devices. Therefore, if the queried screen resolution is 360 x 640 (or 640 x 360 in landscape orientation), you can assume that touch UI is supported. On devices that support WRT 1.1, you can use the DisplayResolution attribute of the ISysInfo.GetInfo() method to determine screen resolution.

+

You can also use the screen width and height attributes to determine screen resolution:

+
// Identifies the device by querying its resolution
+function detectResolution() {
+    var screenWidth = screen.width;
+    var screenHeight = screen.height;
+    
+    if (screenWidth == 240 && screenHeight == 320) {
+        resolution = RESOLUTION_QVGA_PORTRAIT;
+    } else if (screenWidth == 320 && screenHeight == 240) {
+        resolution = RESOLUTION_QVGA_LANDSCAPE;
+    } else if (screenWidth == 360 && screenHeight == 640) {
+        resolution = RESOLUTION_NHD_PORTRAIT;
+    } else if (screenWidth == 640 && screenHeight == 360) {
+        resolution = RESOLUTION_NHD_LANDSCAPE;
+    } else if (screenWidth == 800 && screenHeight == 352) {
+        resolution = RESOLUTION_E90_LANDSCAPE;
+    } else {
+        resolution = RESOLUTION_UNDEFINED;
+    }
+}
+
+// Detects whether touch UI is supported
+function detectTouchUI() {
+		// Query the device resolution to determine whether this is a touch device.
+    if (resolution == RESOLUTION_NHD_LANDSCAPE ||
+        resolution == RESOLUTION_NHD_PORTRAIT) {
+        touchSupported = true;
+    } else {
+        touchSupported = false;
+		}
+}
+
+
\ No newline at end of file