blackberryblackberry-editfield

Editfield scroll fails to reach top in blackberry


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


Solution

  • 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);