Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    48

    switching to the current screen

    when i press the about button am taken to the about form which has a back command.
    when i press the back command it should take me to the current screen that i was on
    instead it takes me to the first screen
    here is my code help me on this;

    Code:
    						 else if(cmd==NextCommand ){
    				 if(d==first){
    					 switchCurrentScreen(second);	
    					 
    				 }else if(d==second){
    					 switchCurrentScreen(third);
    				 }
    				 else if(d==third){
    					 switchCurrentScreen(forth);
    				 }
    				 else if(d==forth){
    					 switchCurrentScreen(fifth);
    					 }
    else if(cmd==PreviousCommand){
    				 if(d==second){
    					 switchCurrentScreen(first);
    				 }else if(d==third){
    					 switchCurrentScreen(second);
    					 }
    				 else if(d==forth){
    					 switchCurrentScreen(third);
    				 }
    				 else if(d==fifth){
    					 switchCurrentScreen(forth);
    					 }
     else if(cmd==AboutCommand){
    				 Display.getDisplay(this).setCurrent(get_aboutForm()); }
    		 else if(cmd==backCommand){
    				Display.getDisplay(this).setCurrent(first);
    		 }
    		 else if(cmd==AboutCommand){
    			 Display.getDisplay(this).setCurrent(get_aboutForm());}
    		 else if(cmd==backCommand){
    			 Display.getDisplay(this).setCurrent(second);
    		 }
    Last edited by wizard_hu_; 2014-03-19 at 22:49. Reason: [CODE][/CODE] and marked a problem

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,807

    Re: switching to the current screen

    That cmd=AboutCommand check and the following few lines are inside the cmd==PreviousCommand block. A closing } may be missing somewhere.
    Also, based on the checks for d==something, I tend to assume that switchCurrentScreen may be a combination of setting d and invoking Display.getDisplay(this).setCurrent. When you use this latter statement directly, d may not get set, and the froward-backward thing is lost.
    And for the paging stuff: PreviousCommand and NextCommand seem to maintain this state tracking approach, e.g. they check d and use switchCurrentScreen, whatever it could be. However the Back command you mention is probably backCommand, and that has two uses in the code, the first one can not run (as it is inside a cmd==PreviousCommand check as mentioned), and the second one is the last line in the code fragment, always switching to "second", it does not check d or anything similar, neither it uses switchCurrentScreen.

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: switching to the current screen

    First of all you have 2 if (cmd == AboutCommand) that are exactly the same (only the first will happen)
    Secondly you are returned to the first screen because that is what you are doing in the code with these lines
    else if(cmd==backCommand){
    Display.getDisplay(this).setCurrent(first);
    }
    since this is the first "if" sentence that compare the cmd to backCommand this is the first "if" that will be execute.

    What I suggest you do is have a member that holds the last screen that was shown before you entered the aboutscreen and then when backCommand is invoked simply show that lastscreen.

    private Displayable latestScreen;

    .
    .
    .



    else if(cmd==AboutCommand){
    latestScreen = Display.getDisplay(this).getCurrent();
    Display.getDisplay(this).setCurrent(get_aboutForm()); }
    else if(cmd==backCommand){
    Display.getDisplay(this).setCurrent(latestScreen );
    }
    Heard of DVLUP? Join here

Similar Threads

  1. switching between screen
    By m-lamaa in forum Symbian User Interface
    Replies: 2
    Last Post: 2010-05-18, 12:49
  2. Replies: 10
    Last Post: 2010-04-20, 07:51
  3. Qt Embedded- Screen switching
    By priya86 in forum [Archived] Qt SDKs and Tools
    Replies: 0
    Last Post: 2009-10-27, 08:08
  4. Switching Screen
    By tieutue in forum Mobile Java Media (Graphics & Sounds)
    Replies: 13
    Last Post: 2008-07-18, 09:16
  5. Replies: 5
    Last Post: 2008-07-11, 22:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×