Controlling the softkeys in Symbian Web Runtime
This code snippet demonstrates how to show and hide the softkey pane, and how to change the right softkey caption and handler.
Article Metadata
Code Example
Tested with
Devices(s): Nokia 5800 XpressMusic, Nokia 6220 Classic
Compatibility
Platform(s): S60 5th Edition, S60 3rd Edition FP2
Article
Keywords: menu.setRightSoftkeyLabel(), menu.showSoftkeys(), menu.hideSoftkeys()
Created: dekuykin
(26 Feb 2009)
Last edited: hamishwillee
(04 Oct 2012)
Contents |
Source file: Relevant HTML components
<input type="button" id="show" value="ENABLE SOFTKEYS" onclick="show();" />
<input type="button" id="hide" value="DISABLE SOFTKEYS" onclick="hide();" />
<p>Set Right Softkey Action</p>
<input type="radio" name="softkeySettings" id="softkeyExit"
onclick="setExit();" />
<label for="softkeyExit">Exit</label>
<input type="radio" name="softkeySettings" id="softkeyAlert"
onclick="setAlert();" />
<label for="softkeyAlert">Alert</label>
Source
/**
* Shows the softkeys.
*/
function show() {
window.menu.showSoftkeys();
}
/**
* Hides the softkeys.
*/
function hide() {
window.menu.hideSoftkeys();
}
/**
* Sets the right softkey handler and label to default.
*/
function setExit() {
window.menu.setRightSoftkeyLabel("", null);
}
/**
* Sets the right softkey handler and label to custom.
*/
function setAlert() {
// Call showAlert() when the softkey is pressed
window.menu.setRightSoftkeyLabel("Alert", showAlert);
}
/**
* Shows an alert message.
*/
function showAlert() {
alert("The right softkey was pressed!");
}
Postconditions
- Clicking the ENABLE SOFTKEYS button makes the softkey pane visible.
- Clicking the DISABLE SOFTKEYS button hides the softkey pane.
- Checking the Exit radio button changes the right softkey to default handler and caption ("Exit").
- Checking the Alert radio button changes the right softkey to custom handler and caption ("Alert").
Supplementary material
This code snippet is part of the stub concept, which means that it has been patched on top of a template application in order to be more useful to developers. The version of the WRT stub application used as a template in this snippet is v1.1.
- The patched, executable application that can be used to test the features described in this snippet is available for download at Media:Controlling softkey in WRT.zip.
- You can view all the changes that are required to implement the above-mentioned features. The changes are provided in unified diff and colour-coded diff (HTML) formats in Media:ControllingSoftkeys.diff.zip.
- For general information on applying the patch, see Using Diffs.
- For unpatched stub applications, see Example app stubs with logging framework.

