×
Namespaces

Variants
Actions

Detecting Location of softkeys in WRT widget

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: isalento (29 Apr 2010)
Last edited: hamishwillee (27 Sep 2012)

Overview

The location of the softkeys is important to know when creating layout for custom UIs or when implementing custom menu structures. In native Symbian applications AknLayoutUtils::CbaLocation() can be used to determinate where the soft keys are placed. In Symbian web runtime the very same value can be accessed by using the built in JavaScript Menu object. Menu object is supported since WRT 1.0. The menu location information is valuable for example when creating a widget with custom UI that should work with N8 and N97 or N97 Mini. They all have the same physical screen size, but the menu location is different for N8 in the landscape mode.


Getting menu location

Menu location can be accessed by inspecting the value of the window.menu.location property. It can have four possible values:

  • -1 menu location is not supported by the system
  • 1 softkeys are located at the left of the device screen
  • 2 softkeys are located at the bottom of the device screen
  • 3 the softkeys are located at the right of the device screen.

As there is no callback to inform when the menu location changes, the value should be checked when the screen size is changed.


Example

window.onresize = function(){
getMenuLocation();
}
 
function getMenuLocation(){
 
switch(window.menu.location){
case -1: alert("not supported"); break;
case 1: alert("softkeys are located on the left of the device screen"); break;
case 2: alert("softkeys are located on the bottom of the device screen"); break;
case 3: alert("softkeys are located on the right of the device screen"); break;
}
 
}
This page was last modified on 27 September 2012, at 07:31.
83 page views in the last 30 days.