4

I am having 2 EditFields in my login form with names Email: and Password:. Just below email I have login button. Suppose I come down till login, I can scroll back only till password field.The cursor fails to reach Email field. In simulator, I tried using arrow keys as well as trackpad. Please help how to scroll back to first editfield

AbsoluteFieldManager ab = new AbsoluteFieldManager();

  add(ab);
  new SeparatorField();

     et=new EditField("Email-id:","");
     pwd=new PasswordEditField("Password:",""); 

     ab.add(et,35,110); 
     ab.add(pwd,35,150); 

I am using AbsoluteFieldManager and developing for OS 6.0. I want the loginscreen to look like facebook login page. Kindly let me know what can possibly be the reason for not able to scroll up

CRUSADER
  • 5,486
  • 3
  • 28
  • 64
Rashmi.B
  • 1,787
  • 2
  • 18
  • 34

4 Answers4

2

It also may be a RIM bug. What OS do you use? Is it OS 5+? Do you use custom paddings/margins/borders for some of the UI elements on the screen (including the screen itself)? If yes, try to comment out any code that sets paddings/margins/borders to check whether this it the case.

Vit Khudenko
  • 28,288
  • 10
  • 63
  • 91
  • I am using AbsoluteFieldManager. If I create two AbsoluteFieldManager, one for username, password and the other for login button, forgot password sections, then i can scroll back to username....but the login fields are going to next page – Rashmi.B Oct 03 '11 at 07:38
  • I've never used `AbsoluteFieldManager`, because usage of this class looks to me as a hack (that's why I avoid it). Your case is **probably** related to the fact you use `AbsoluteFieldManager`. Sorry in advance if this sounds a bit offensive, however ask yourself - do you really need it OR this is because you don't understand BB UI API at a level that allows to create screen layout using default components? – Vit Khudenko Oct 03 '11 at 12:59
  • This is a requirement which is why I am using AbsoluteFieldManager. My App logo appears the center top and below that, the user login credentials should be maintained. As per the layout, I learnt about this manager. Anyways thanks a ton for your help. I appreciate it – Rashmi.B Oct 04 '11 at 05:06
  • Need of `AbsoluteFieldManager` usage is probably a sign that you need a custom `Manager` for your login screen. – Vit Khudenko Oct 04 '11 at 07:04
  • Yes. In short I want to display something like facebook login page. Facebook login at the top and the credentials at the bottom – Rashmi.B Oct 04 '11 at 07:09
2

Maybe it is a RIM bug with the AbsoluteFieldManager. Never used it before so I don't know about it. You can create a work around to solve this problem. Find it below:

et=new EditField("Email-id:","");
pwd=new PasswordEditField("Password:","") {
    protected int moveFocus(int amount, int status, int time) {
        int cursorPosition = this.getCursorPosition();
        if ((cursorPosition == 0) && (amount < 0)) {
            et.setFocus();
            return 0;
        }
        else {
            return super.moveFocus(amount, status, time);
        }
    }
}; 

In this way, when you arrive to the first element in the password edit field, you will oblige the email field to get focused. This will work for you as a work around.

Another way to solve the problem is to add the two fields in an horizontal field manager, in that way I guess this will work for you for sure. If not use the first method. You can find below the code for HorizontalFieldManager:

 et=new EditField("Email-id:","");
 pwd=new PasswordEditField("Password:",""); 
 HorizontalFieldManager manager = new HorizontalFieldManager();
 manager.add(et);
 manager.add(pwd);
 ab.add(manager, yourX, yourY);
Farid Farhat
  • 2,300
  • 1
  • 16
  • 29
0

You can use this code for your login page:

public class loginscreen extends MainScreen implements FieldChangeListener {

private int deviceWidth = Display.getWidth();
private int deviceHeight = Display.getHeight();
private VerticalFieldManager subManager;
private VerticalFieldManager mainManager;
public long mycolor = 0x00FFFFFF;

Screen _screen = home.Screen;
TextField heading = new TextField(Field.NON_FOCUSABLE);

TextField username_ef = new TextField();
PasswordEditField password_ef = new PasswordEditField();
CheckboxField rememberpass = new CheckboxField();   
public ButtonField login_bt = new ButtonField("Login", ButtonField.CONSUME_CLICK);
public ButtonField register_bt = new ButtonField("Register", ButtonField.CONSUME_CLICK);

public loginscreen()
{
    super();
    final Bitmap backgroundBitmap = Bitmap.getBitmapResource("bgd.png");

    HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR )

    {

    protected void sublayout(int width, int height) 

    {

    Field field;

    int numberOfFields = getFieldCount();

    int x = 245;

    int y = 0;

    for (int i = 0;i < numberOfFields;i++) 

    {

    field = getField(i);

    setPositionChild(field,x,y); 

    layoutChild(field, width, height);

    x +=_screen.getWidth()-381;

    y += 0;//l17

    }

    width=_screen.getWidth();

    height=48;//w19

    setExtent(width, height);

    }

    };


   mainManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR )
    {

        public void paint(Graphics graphics)
        {
            graphics.clear();
            graphics.drawBitmap(0, 0, deviceWidth, deviceHeight, backgroundBitmap, 0, 0);                       
            super.paint(graphics);
        }            
    };
  //this manger is used for adding the componentes
    subManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR )
    {
        protected void sublayout( int maxWidth, int maxHeight )
        {
            int displayWidth = deviceWidth;
            int displayHeight = deviceHeight;

            super.sublayout( displayWidth, displayHeight);
            setExtent( displayWidth, displayHeight);
        }

        public void paint(Graphics graphics)

        {
            graphics.setColor((int) mycolor);
        super.paint(graphics);

        }
    }; 


    username_ef.setLabel("Username: ");
    password_ef.setLabel("Password: ");
    rememberpass.setLabel("Remember Password");
    heading.setLabel("Please enter your credentials: ");

    username_ef.setMaxSize(8);
    password_ef.setMaxSize(20);

    subManager.add(heading);
    subManager.add(username_ef);
    subManager.add(password_ef);
    subManager.add(rememberpass);
    subManager.add(new SeparatorField());
    login_bt.setChangeListener(this);   
    register_bt.setChangeListener(this); 

    hfm.add(login_bt);
    hfm.add(register_bt);
    subManager.add(hfm);

    mainManager.add(subManager);
    this.add(mainManager);

}

public boolean onSavePrompt()
{
    return true;
} 


public void fieldChanged(Field field, int context) {
    // TODO Auto-generated method stub 
    if(field == login_bt)
    {
        //do your code for login button click           
    }

    if(field == register_bt)
    {
        //code for register button click
    }
}}
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Arun Kumar Munusamy
  • 871
  • 1
  • 10
  • 28
-2

What you have described is not normal behavior.

My conclusion is that your code has one or more bugs, in order to solve your problem you should modify your code to fix the bugs. You will then be able to scroll up and down through the various fields.

note: As this question stands it's not possible for me to be more specific about the exact bugs. So instead I will show you an example of the layout you described that would scroll properly and you can use as a default to determine which of your deviations have caused your bugs.

// inside MainScreen constructor
add(new EditField("Username:","",0));
add(new EditField("Password:","",0));
add(new ButtonField(buttonBMP,ButtonField.CONSUME_CLICK));
  • (not my downvote) but this response is not particularly helpful to answering the question – Robert Martin Oct 02 '11 at 03:28
  • @RobertMartin This is very unfair, I could not be specific about the bug because the question did not contain any code. Ask a broad question, get a broad answer, don't blame the answerer. Come on man, I need to get to 100000 – Gupta Patel Oct 03 '11 at 04:58