Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Dipanwita_Das
Posts: 75
Registered: ‎07-22-2010
My Device: Not Specified
My Carrier: Trainee

my code is not running rightly.. Whatis the prob in this code

I want to delete a editField when backspace is pressed and the field is empty. But any how it is not cheking the case under which I am checking if backspace is pressed. To check it I have kept a println function. But println not working. Here I want to delete toFld which is dynamically added.

 

 

 

 

protected boolean keyControl(char key,
                             int status,
                             int time)
   {
       switch(key)
       {
           
       case Characters.BACKSPACE:
       {
       
            if(vfm.getFieldWithFocus()!= toFld)
            {
            int index = vfm.getFieldWithFocus().getIndex();
                System.out.println("====================="+index+"======================================================");
                return true;
             }
            //if(vfm.getFieldWithFocus().getText().length()==0)
            else
            {
                //EditField currentField=new EditField();
                //currentField= vfm.getFieldWithFocus();
                int start= toFld.getIndex();
                System.out.println("++++++++++++++++++++++++++++++"+start+"++++++++++++++++++++++++++++++++++++++++++++");
                //vfm.deleteRange(start,1);
                
                vfm.delete(toFld);
                vfm.getField(start-1).setFocus();
                invalidate();
                return true;
            }
            
         
        }
        case Characters.ENTER :
        {
            System.out.println("Hiiiiiiiiiiiiiiii ENTER is selected");
        }
              
       }
       System.out.println("00000000000000))))))))))))))))))))))))");
       return true;
   }

 

Please give me a solution

thank you

 

Please use plain text.
Developer
mbasheerk
Posts: 326
Registered: ‎02-02-2009
My Device: Not Specified

Re: my code is not running rightly.. Whatis the prob in this code

try with

protected boolean keyChar(char character, int status, int time){}

 

Please use plain text.
Regular Contributor
Dipanwita_Das
Posts: 75
Registered: ‎07-22-2010
My Device: Not Specified
My Carrier: Trainee

Re: my code is not running rightly.. Whatis the prob in this code

If I do it with key char then I can not write in the EditField if I want to.

I m deleteing the Edit Field because when it is not needed i will delete it by clicking the backspace.

Please use plain text.