|
1 |
|
2 <!DOCTYPE html |
|
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="concept"/><meta name="DC.Title" content="Checking for touch support"/><meta name="abstract" content="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."/><meta name="description" content="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."/><meta name="DC.Relation" scheme="URI" content="GUID-04ABC9FC-26FE-4854-9F88-63A2C4911886"/><meta name="DC.Relation" scheme="URI" content="GUID-13E2DE63-47E5-4E2A-85FF-C8B0CAB9D4DE"/><meta name="DC.Relation" scheme="URI" content="GUID-D54DEFE7-E878-4530-B707-A5388DFE1D9D"/><meta name="DC.Relation" scheme="URI" content="GUID-6DD2B3D2-BA3B-4936-BBC9-F61B6757B6F8"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-AE9BB3E0-C243-476B-A236-40958A1DAED9"/><meta name="DC.Language" content="en"/><title>Checking for touch support </title><script type="text/javascript"> |
|
5 function initPage() {} |
|
6 </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-AE9BB3E0-C243-476B-A236-40958A1DAED9">Checking for touch support</h1><div><p>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.</p> |
|
7 <p>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<code> DisplayResolution</code> attribute of the <a href="GUID-279A3698-D09B-44BF-8340-739E19F94727.html#GUID-279A3698-D09B-44BF-8340-739E19F94727"><code>ISysInfo.GetInfo()</code></a> method to determine screen resolution.</p> |
|
8 <p>You can also use the screen width and height attributes to determine screen resolution:</p> |
|
9 <pre class="codeblock">// Identifies the device by querying its resolution |
|
10 function detectResolution() { |
|
11 var screenWidth = screen.width; |
|
12 var screenHeight = screen.height; |
|
13 |
|
14 if (screenWidth == 240 && screenHeight == 320) { |
|
15 resolution = RESOLUTION_QVGA_PORTRAIT; |
|
16 } else if (screenWidth == 320 && screenHeight == 240) { |
|
17 resolution = RESOLUTION_QVGA_LANDSCAPE; |
|
18 } else if (screenWidth == 360 && screenHeight == 640) { |
|
19 resolution = RESOLUTION_NHD_PORTRAIT; |
|
20 } else if (screenWidth == 640 && screenHeight == 360) { |
|
21 resolution = RESOLUTION_NHD_LANDSCAPE; |
|
22 } else if (screenWidth == 800 && screenHeight == 352) { |
|
23 resolution = RESOLUTION_E90_LANDSCAPE; |
|
24 } else { |
|
25 resolution = RESOLUTION_UNDEFINED; |
|
26 } |
|
27 } |
|
28 |
|
29 // Detects whether touch UI is supported |
|
30 function detectTouchUI() { |
|
31 // Query the device resolution to determine whether this is a touch device. |
|
32 if (resolution == RESOLUTION_NHD_LANDSCAPE || |
|
33 resolution == RESOLUTION_NHD_PORTRAIT) { |
|
34 touchSupported = true; |
|
35 } else { |
|
36 touchSupported = false; |
|
37 } |
|
38 } |
|
39 </pre> |
|
40 </div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html> |