BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   BB screen navigation issues - <FULL MENU> <HOLD> (http://www.blackberryforums.com/developer-forum/191050-bb-screen-navigation-issues-full-menu-hold.html)

itp 05-23-2009 09:48 AM

BB screen navigation issues - <FULL MENU> <HOLD>
 
I am trying to build a simple menu using ButtonFields. I am able to navigate from screen to screen.

Testing on the emulator, if I use the "Enter Button" or Enter key on my beyboard, I can navigate from Screen A to Screen B. However if I use the Pearl trackball, I get I get <Full Menu> and then <Close> menu options.

What technique can I use to skip these menu options in an application. I also tried variations of super(DEFAULT_MENU | DEFAULT_CLOSE), with no success.

Please respond gently, as I am still quite new with this.

thank you


PHP Code:

import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;

class 
MenuMain extends UiApplication
{
   public static 
void main(Stringxxx91;xxx93; args)    
   {  
        
MenuMain theApp = new MenuMain();
        
theApp.enterEventDispatcher();       
   } 
   public 
MenuMain()   
   {
       
pushScreen(new MenuButtonScreenA());   
   }   
}

import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;

public class 
MenuButtonScreenA extends MainScreen implements FieldChangeListener
{
    private 
ButtonField b1,b2;
    public 
MenuButtonScreenA()
    {
        
super(DEFAULT_MENU);
        
LabelField title = new LabelField("Menu Button Test Screen -A-" ,LabelField.ELLIPSIS |  LabelField.USE_ALL_WIDTH); 
        
setTitle(title);           
         
        
b1 = new ButtonField("Go To Screen B");    
        
b2 = new ButtonField("Go To Screen C");       
        
this.add(b1);
        
this.add(b2);
        
b1.setChangeListener(this);
        
b2.setChangeListener(this);
    }
   
    public 
void fieldChanged(Field fieldint context)
    {
         if(
field instanceof ButtonField)
         {        
             
String lbl = ((ButtonField)field).getLabel();
        
             if(
lbl.equals("Go To Screen B"))
             {   
                 
MenuButtonScreenB sc = new MenuButtonScreenB();
                 
UiApplication.getUiApplication().pushScreen(sc);
             }
             
             if(
lbl.equals("Go To Screen C"))
             {
                 
Dialog.alert("This will soon take you to Screen C");
                 
//MenuButtonScreenC sc = new MenuButtonScreenC();
                 //UiApplication.getUiApplication().pushScreen(sc);
             
}
        }   
    }

  
//override the onClose() method to display a dialog box to the user with "Goodbye!" when the application is closed
   
public boolean onClose()
   {
       
Dialog.alert("Goodbye!");
       
System.exit(0);
       return 
true;
   }
}

 
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;

public class 
MenuButtonScreenB extends MainScreen implements FieldChangeListener
{
    private 
ButtonField b1,b2;

    public 
MenuButtonScreenB()
    {
        
super(DEFAULT_MENU);
        
LabelField title = new LabelField("Menu Button Test Screen -B-" ,LabelField.ELLIPSIS |  LabelField.USE_ALL_WIDTH); 
        
setTitle(title);           
         
        
b1 = new ButtonField("Go To Screen B-1");    
        
b2 = new ButtonField("Go To Screen B-2");       
        
this.add(b1);
        
this.add(b2);
        
b1.setChangeListener(this);
        
b2.setChangeListener(this);         
    }
    
    public 
void fieldChanged(Field fieldint context)
    {
         if(
field instanceof ButtonField)
         {        
             
String lbl = ((ButtonField)field).getLabel();
        
             if(
lbl.equals("Go To Screen B-1"))
             {            
                 
Dialog.alert("This will soon take you to Screen B-1");
                 
//MenButtonScreenB sc = new MenButtonScreenB();
                 //UiApplication.getUiApplication().pushScreen(sc);
             
}
             
             if(
lbl.equals("Go To Screen B-2"))
             {
                 
Dialog.alert("This will soon take you to Screen B-2");
                 
//MenButtonScreenC sc = new MenButtonScreenC();
                 //UiApplication.getUiApplication().pushScreen(sc);
             
}
        }   
    }    
    
    public 
boolean onClose()
    {  
       
setDirty(false);
       return 
super.onClose();
   }    



itp 05-23-2009 02:51 PM

I was able to solve this by using a FieldChangeListener like this. But it seems like a cludgy solution. Any better ideas?

Quote:

b1 = new ButtonField("Goto Screen B",ButtonField.CONSUME_CLICK);
b1.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
MenuButtonScreenB sc = new MenuButtonScreenB();
UiApplication.getUiApplication().pushScreen(sc);
}
});
this.add(b1);
PHP Code:

import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;

class 
MenuMain extends UiApplication
{
   public static 
void main(Stringxxx91;xxx93; args)    
   {  
        
MenuMain theApp = new MenuMain();
        
theApp.enterEventDispatcher();       
   } 
   public 
MenuMain()   
   {
       
pushScreen(new MenuButtonScreenA());   
   }   
}

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.*;

public class 
MenuButtonScreenA extends MainScreen 
{
    private 
ButtonField b1,b2;
    private 
ButtonField buttonSel;
    
    public 
MenuButtonScreenA()
    {
        
super(DEFAULT_MENU);
        
LabelField title = new LabelField("Menu Button Test Screen -A-" ,LabelField.ELLIPSIS |  LabelField.USE_ALL_WIDTH); 
        
setTitle(title);           
        
        
//--------------
        
b1 = new ButtonField("Goto Screen B",ButtonField.CONSUME_CLICK);
        
b1.setChangeListener(new FieldChangeListener()
        {
            public 
void fieldChanged(Field fieldint context)
            {
                
MenuButtonScreenB sc = new MenuButtonScreenB();
                
UiApplication.getUiApplication().pushScreen(sc);
            }
        });
        
this.add(b1);
        
//--------------        
        
b2 = new ButtonField("Goto Screen C",ButtonField.CONSUME_CLICK);
        
b2.setChangeListener(new FieldChangeListener()
        {
            public 
void fieldChanged(Field fieldint context)
            {
                
MenuButtonScreenC sc = new MenuButtonScreenC();
                
UiApplication.getUiApplication().pushScreen(sc);
            }
        });
        
this.add(b2);
        
//--------------
        
    
}
    

  
//override the onClose() method to display a dialog box to the user with "Goodbye!" when the application is closed
   
public boolean onClose()
   {       
       
boolean retval false;
       
int response Dialog.ask(Dialog.D_YES_NO"Are you sure you want to Exit now?"Dialog.NO);     
       if(
response==Dialog.YES)
       {                
           
System.exit(0);
           
retval true;       
       }       
       return 
retval;
   }   
}

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.*;


public class 
MenuButtonScreenB extends MainScreen 
{
    private 
ButtonField b1,b2;

    public 
MenuButtonScreenB()
    {
        
super(DEFAULT_MENU);
        
LabelField title = new LabelField("Menu Button Test Screen -B1-" ,LabelField.ELLIPSIS |  LabelField.USE_ALL_WIDTH); 
        
setTitle(title);           
         
        
//--------------
        
b1 = new ButtonField("Goto Screen B-1",ButtonField.CONSUME_CLICK);
        
b1.setChangeListener(new FieldChangeListener()
        {
            public 
void fieldChanged(Field fieldint context)
            {
                
Dialog.alert("This will soon take you to Screen B-1");
            }
        });
        
this.add(b1);
    }
    
    public 
boolean onClose()
    {  
       
setDirty(false);
       return 
super.onClose();
   }       
}

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;

public class 
MenuButtonScreenC extends MainScreen
{
    private 
ButtonField b1,b2;

    public 
MenuButtonScreenC()
    {
        
super(DEFAULT_MENU);                                
        
LabelField title = new LabelField("Menu Button Test Screen -C1-" ,LabelField.ELLIPSIS |  LabelField.USE_ALL_WIDTH); 
        
setTitle(title);           
         
        
//--------------
        
b1 = new ButtonField("Goto Screen C-1",ButtonField.CONSUME_CLICK);
        
b1.setChangeListener(new FieldChangeListener()
        {
            public 
void fieldChanged(Field fieldint context)
            {
                
Dialog.alert("This will soon take you to Screen C-1");
            }
        });
        
this.add(b1);
    }
    
    public 
boolean onClose()
    {  
       
setDirty(false);
       return 
super.onClose();
   }       



Dougsg38p 05-24-2009 01:25 PM

You could have added the CONSUME_CLICK style to your button field - this would keep the menu from poppin up.


All times are GMT -5. The time now is 01:07 PM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.