The WDN Symbian DevZone... MobileVB development for the Nokia 9200 series continued
by Richard Bloor, October 7, 2002
This week we continue our series on AppForge MobileVB development for the
Nokia 9200 series with a detailed look at implementing Nokia compliant
navigation in a data entry screen.
We have already discussed the differences in the User Interface paradigms
between Nokia Series 80, the UI for the Nokia 9200 series communicators, and
native Windows navigation, which is the default use in AppForge (See Article).
We will now proceed to look at the coding required to implement navigation using
the cursor keys rather than tab to move between data entry fields in a screen.
The example for this exercise is a simple data entry screen for an event logging
application. At this stage all I have done is defined the screen layout with labels
and text fields for the data I want to store. The fields for time and date are simply
placeholders at this stage, we will come back and look at handling time and date
entry in a later session, as we are simply concentrating on implementing cursor
based navigation in this session.
Before we start looking at the navigation it is worth noting that when you create a
new Series 80 project there is a module called modNokiaKeyCodes created by
default. This module defines a number of constants which contain the
appropriate key codes for a number of keys, menu, zoom in, zoom out which
differ between Visual Basic run natively and the compiled MobileVB application
when run in the Nokia 9200 series emulator or on a Nokia 9200 series machine.
The code is well commented and does not justify further explanation here.
Capturing Keyboard Information
To implement Series 80 style Navigation the AppForge MobileVB facility to
capture and process keyboard input is used. This facility is turned on by default
in all Nokia Series 80 projects with each formís KeyPreview property to True.
With KeyPreview on three events can be captured KeyDown, KeyUp and KeyPress.
The KeyDown and KeyUp events occur whenever a key is pressed and then
released. Both events return the same two parameters, the first is the ScanCode,
a unique integer representing the key that was pressed, and the second is a byte
mask, called Shift, that indicates what special key, Shift or Control, was also
being pressed when the event was fired. Shift returns three values to indicate
whether the Shift, Control or both Shift and Control were being pressed.
Series 80 also has a third modifier key, the Chr key. As this key is not return by
Shift you will need to write additional code to detect that it is being used as a
The third key event captured is KeyPress. Unlike the other two events KeyPress
fires only when a printable character is input into the device. It also has only one
parameter, KeyAscii, which returns the ASCII value for the key pressed on the
On Opening the Form
On opening a form the cursor automatically is placed within the first field on the
screen. The way the Series 80 interface works means that not all fields have an
active cursor, so to show the user which field they are in the current fields text
label is highlighted. This requirements is handled in the Formís Load event.
So in this example I have added the following code:
The first line sets the active field counter to 1 and highlights the first fields label.
The second is a variable which stores the maximum number of fields that are on
Having loaded the form we now need to capture and act on the keyboard events.
A standard skeleton is added to each Series 80 form that is created that includes
all the main key actions we will need to act upon. Interestingly the skeleton does
not include the code required to act on the Chr key.
In this example we are only acting on the key down event, for brevity, the sections
of the Case statements dealing with the menu button, zoom in, zoom out and left
and right cursor movements have been removed.
This section of code has captured the up and down cursor keys and increased or
decreased the field number. Next all the label highlighting is cleared. It may be
more efficient to clear only the previous fields label highlighting but there appears
to be no obvious difference when running the application and clearing all the
highlighting is arguable easier to code.
Now we use the ActiveField value to set the focus and highlight the label of the
field we want to move to.
We have now seen how to implement cursor key navigation in a simple data entry
screen. There are however some limitations on how compliant the interface can
be with the current version of MobileVB.
These limitations include:
- multiple line text fields. MobileVB does not currently have a mechanism to
detect that the cursor is at the start or end of the text. This means that you
can not implement a text field with correct navigation as a continuous part of a
data entry screen. This can be overcome by placing the text field in its own
pane and using tab to navigate between panes.
- Drop down lists are opened using the enter (return) key in MobileVB rather
than the tab key used on the Nokia. The left and right cursor can however be
used to cycle through the list of available values in the same manner to the
In this article we have seen how to use the KeyDown event to capture keystrokes
and override the native windows navigation and to implement Nokia style
navigation. We have also briefly reviewed the areas where currently it is not
possible to correctly implement Nokia style navigation.
Next time we will look at adding additional control to our example screen to allow
for entering time and date values.
About the WDN Symbian Editor, Richard Bloor:Symbian DevZone Home
Richard Bloor has 16 years experience in the IT industry. His earlier
work was largely in design and development of commercial and
manufacturing systems but more recently has focused on
development and test management of government systems.
Richard Bloor is the Mobile Applications champion at System
Architecture consultancy Equinox of Wellington, New Zealand.
Richard can be reached at firstname.lastname@example.org.