Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 20:19, 6 March 2008.

Change widget's views triggered by the options menu

From Forum Nokia Wiki

Compatibility

WRT 1.0

Description

Widget's HTML elements such as inputs, buttons, texts, images etc. can be shown or hidden dynamically using the JavaScript DOM style object.

To hide an element call [element].style.display = "none";
To show an element call [element].style.display = "block";

If the code above is called as a consequence of a selection of a menu item from the Options menu or of a click on the right softkey (if it was overridden the default "exit" function), the element is not shown or hidden immediately, but the effect happens only after the user clicks on a key on the keypad (navigation keys or a numeric key).

Example codes

  function showSettingView()
  {
    document.getElementById('mainView').style.display = "none";
    document.getElementById('settingView').style.display = "block";
    // change default right softkey label and override default function
    window.menu.setRightSoftkeyLabel("Back", returnToMainView);
  }
  function showMainView()
  {
    document.getElementById('mainView').style.display = "block";
    document.getElementById('settingView').style.display = "none";
    // change default right softkey label and override default function
    window.menu.setRightSoftkeyLabel("Settings", showSettingView);
  }

The example code above allows a user to switch between the main view and the setting view by clicking on the right softkey, but the view is not changed immediately.

Solutions

To overcome the problem, choose one of the options below:

Solution 1: Implement a separate function which handles the widget's display switching and use the setTimeout() to cause a small delay.

Example codes

  function showSettingView()
  {
    // change default right softkey label and override default function
    window.menu.setRightSoftkeyLabel("Back", returnToMainView);
    setTimeout("switchViews(0);", 1);
  }
  function showMainView()
  {
    // change default right softkey label and override default function
    window.menu.setRightSoftkeyLabel("Settings", showSettingView);
    setTimeout("switchViews(1);", 1);
  }
  function switchViews(mainView)
  {
    if (mainView) {
       document.getElementById('mainView').style.display = "block";
       document.getElementById('settingView').style.display = "none";
       }
    else {
       document.getElementById('mainView').style.display = "none";
       document.getElementById('settingView').style.display = "block";
       }
  }

Solution 2: Use the widget.prepareForTransition() and widget.performTransition() methods and use the setTimeout() to cause a small delay.

Example codes

  function showSettingView()
  {
    window.widget.prepareForTransition("fade");
    document.getElementById('mainView').style.display = "none";
    document.getElementById('settingView').style.display = "block";
    setTimeout("window.widget.performTransition();", 1);
    // change default right softkey label and override default function
    window.menu.setRightSoftkeyLabel("Back", returnToMainView);
  }
  function showMainView()
  {
    window.widget.prepareForTransition("fade");
    document.getElementById('mainView').style.display = "block";
    document.getElementById('settingView').style.display = "none";
    setTimeout("window.widget.performTransition();", 1);
    // change default right softkey label and override default function
    window.menu.setRightSoftkeyLabel("Settings", showSettingView);
  }
Related Discussions
Thread Thread Starter Forum Replies Last Post
cba for selection list dialog ninidotnet Symbian User Interface 16 2006-05-17 05:59
multi-views fullscreen problem fishman8 General Symbian C++ 0 2007-08-31 20:33
上次在document中看到了如何切换显示View的步骤 draker Symbian 5 2005-05-31 14:37
CeikDialog and options menu babk Symbian User Interface 0 2005-12-28 17:41
Dictionary for Autospelling. guillot Smart Messaging 3 2003-03-13 05:27
 
Powered by MediaWiki