Professional Documents
Culture Documents
10
2|Page
Contents
Introduction ............................................................................................................................................ 3
Configuration .......................................................................................................................................... 4
Usage....................................................................................................................................................... 4
Setting focusable elements................................................................................................................. 4
Navigation Map ................................................................................................................................... 5
JavaScript Extensions .......................................................................................................................... 5
Initial Focus ......................................................................................................................................... 5
Focus Effect ......................................................................................................................................... 5
DOM Events in Navigation Mode............................................................................................................ 6
Example ................................................................................................................................................... 6
Links ........................................................................................................................................................ 7
3|Page
Introduction
System Requirements:
* Note:
This tutorial is only applicable for trackpad/trackball devices. The new navigation mode will not
change the user experience on any touch screen devices.
This tutorial will cover how to configure the new navigation mode for BlackBerry Widgets. The
navigation mode allows BlackBerry Widgets to create a user experience that is closely comparable to
the experience that a user would get while using a Java® Application. By default, the navigation
mode displays the pointer to the user for navigation, however with the new navigation mode
enabled, the user will be able to highlight sections of the application for navigation.
The new navigation mode can go a long way in making your user interface a lot easier to navigate
through. If you have specific areas of the page you’d like to have control navigation, you can add
them to the navigation mode and allow the cursor to go directly to those areas.
4|Page
Configuration
There are two ways to enable the new navigation mode.
b. Add the element <rim:navigation mode="focus" /> as a child to the ‘Widget’ element:
2. Use the BlackBerry® Web Plug-in for Microsoft® Visual Studio® or Eclipse®
Usage
Running a BlackBerry Widget with the new navigation mode under a non-trackball device (such as
BlackBerry® Storm™ smartphone or the BlackBerry® Storm2™ smartphone) will result in the same
behaviour as running the BlackBerry Widget without specifying a navigation mode.
If you would like to use any of the default elements without being focusable from the navigation
map, which will prevent the element from getting focus, add the attribute x-blackberry-focusable
with the value set to “false”:
Navigation Map
By default the focus of the HTML elements will scroll accordingly to the direction of the
trackball/trackwheel, however this behaviour can be overridden and customized by using the "x-
blackberry-onUp", "x-blackberry-onDown", "x-blackberry-onLeft", and “x-blackberry-onRight"
attributes.
If “input1” is currently focused and the user scrolls up on the trackball/trackpad, “SomeJsFunction”
will be executed instead of the default focus behaviour of moving the focus up, and unless
SomeJsFunction programmatically changes the focus, the current focus won’t change.
JavaScript® Extensions
To assist developers in changing focus easily, we have added the “blackberry.focus” JavaScript
extension to the existing JavaScript Engine for the needs of the nagivation mode:
Initial Focus
By default, the “highest” or “first” focusable element will be initially focused when the document is
loaded. You can override this behavior using the x-blackberry-initialFocus attribute:
Focus Effect
By default, when an element is focused, we will draw a light blue rectangle around the dimension of
the element. This effect can be customized using the CSS “:hover” pseudo-classes.
.list
{
width: 100%;
display: block;
text-decoration: none;
}
.list:hover
{
background-color: red;
color: white;
}
6|Page
As well you can also disable the default hover effect, which is the light blue round rectangle box, by
adding a meta tag to your HTML page:
An element can gain focus when the user moves the scroll wheel under the default
navigation behaviour or the JavaScript Extension API navigation.setRimFocus is called to
programmatically set the focus to an element
When the user presses the scroll wheel, the current focused element will receive
“mousedown”, “mouseup” and “click” in sequence if it doesn’t consume these actions
as UI events in advance.
Example
The following is a quick example to help you get up and running with the new navigation mode. All
of the tools, tips and techniques above can be applied to this example to extend on it for you to
discover the new navigation mode and how it can benefit your BlackBerry Widget.
Config.xml:
Index.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<meta name="viewport" id="viewport" content="initial-scale=1.0,user-scalable=no" />
<title>Untitled Page</title>
<style type="text/css">
.myCell
{
background-color:Green;
}
.myCell:hover
{
background-color: blue;
}
</style>
</head>
<body>
<table>
<tr>
<td class="myCell" x-blackberry-focusable="true">Cell 1</td>
<td class="myCell" x-blackberry-focusable="true">Cell 2</td>
<td class="myCell" x-blackberry-focusable="true">Cell 3</td>
</tr>
<tr>
<td class="myCell" x-blackberry-focusable="true">Cell 4</td>
<td class="myCell" x-blackberry-focusable="true">Cell 5</td>
<td class="myCell" x-blackberry-focusable="true">Cell 6</td>
</tr>
<tr>
<td class="myCell" x-blackberry-focusable="true">Cell 7</td>
<td class="myCell" x-blackberry-focusable="true">Cell 8</td>
<td class="myCell" x-blackberry-focusable="true">Cell 9</td>
</tr>
</table>
</body>
</html>
Links
BlackBerry Widgets Web Site:
http://www.blackberry/developers/widget
Documentation:
http://na.blackberry.com/eng/support/docs/developers/?userType=21
Forums:
http://supportforums.blackberry.com/rim/?category.id=BlackBerryDevelopment
©2010 Research In Motion Limited. All rights reserved. BlackBerry®, RIM®, Research In Motion®,
SureType®, SurePress™ and related trademarks, names and logos are the property of Research In
Motion Limited and are registered and/or used in the U.S. and countries around the world.