BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-23-2009, 10:48 AM   #1 (permalink)
itp
Knows Where the Search Button Is
 
Join Date: Jul 2008
Model: none
PIN: N/A
Carrier: none
Posts: 24
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default BB screen navigation issues - <FULL MENU> <HOLD>

Please Login to Remove!

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();
   }    

Offline  
Old 05-23-2009, 03:51 PM   #2 (permalink)
itp
Knows Where the Search Button Is
 
Join Date: Jul 2008
Model: none
PIN: N/A
Carrier: none
Posts: 24
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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();
   }       

Offline  
Old 05-24-2009, 02:25 PM   #3 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

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


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.