diff -r 913c9751c067 -r 716254ccbcc0 org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-5B0BE2FA-9FBB-4B8D-A1CE-219634C9C27A.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-5B0BE2FA-9FBB-4B8D-A1CE-219634C9C27A.html Fri Mar 05 19:11:15 2010 -0800 @@ -0,0 +1,52 @@ + + +Determining +whether to display home screen or full screen

Determining +whether to display home screen or full screen

A widget enabled for the home screen has two views, home screen +view and a full screen view. You must implement a function in your widget +that determines in which view to display the widget and call that function +in response to communication from the home screen.

+

The home screen communicates with the widget when users interact with the +home screen. Communication between the home screen and the widget occurs at +the system level, so it happens automatically. When the widget receives communication +from the home screen, it fires the following events:

+
    +
  • onload() and onshow() when +users add a widget to the home screen.

  • +
  • onshow() and onresize() when +the mobile device user selects a home screen widget to launch it in full view.

  • +
  • onshow() and onresize() when +the home screen moves from the background to the foreground.

  • +
+

To determine which view to display

    +
  1. Write JavaScript code +that determines the current screen size and uses that value to initialize +either the home screen view or the full screen view.

    For example, the +following functions set a threshold value of 150 pixels to determine whether +to display the widget in full screen view (initFull) +or home screen view (initHomeScreen).

    function setViewMode(){
    +   var isInHSView = isHSViewMode();
    +	
    +   if ( isInHSView ) {
    +       initHomeScreen();
    +		   
    +	 } else {
    +		   initFull();
    +   }
    +}
    +
    isHSViewMode: function() {
    +	   var size = this.getScreenSize();
    +	   return ( size.height < HS_VIEW_TRESHOLD );
    +}	
    +
    +
    HS_VIEW_TRESHOLD = 150;
    +
  2. +
  3. Call the setViewMode() function +in response to onload(), onshow(), and onresize() events +fired by the widget UI.

    For example, the following HTML code calls setViewMode() in +response to these events.

    <body id="body" onload="setViewMode();" onshow="setViewMode();" onresize="setViewMode();">
  4. +

For an example, see Enabling STEW for the home screen.

+
\ No newline at end of file