trackroll does not works as i want or expect to do,blackberry

Posted by SWATI on Stack Overflow See other posts from Stack Overflow or by SWATI
Published on 2010-04-30T13:41:56Z Indexed on 2010/05/01 6:27 UTC
Read the original article Hit count: 290

Filed under:
|

i am working on blackberry curve 8300

i have added some components in the main screen,now i want to move the focus vertically when the trackball moves up or down and move the focus horizontally when track-Wheel moves left or right.

==================================================================================

--Title area that contains a focusable field(BACK)--
--Non focusable Label field that indicates the name of the user--
--A horizontal field manager1 that contains 4 buttons--
--A horizontal field manager2 that contains 4 buttons--
--A horizontal field manager2 that contains 4 buttons--

==================================================================================

now suppose currently focus is on BACK button and i scroll the track-wheel downwards then, focus should come on 1st button of manager1 Again when i scroll downwards,then focus should come on the 1st button of manager2 and not the 2nd button of manager1(as its happening on device)

my code is :::

protected boolean trackwheelRoll(int amount, int status, int time) 
{
 focusIndex = this.getFieldWithFocusIndex();
 System.out.println("focus index ::::::::::::::::"+focusIndex);
 Field f;
 if(focusIndex!=0)
 {
   if(amount==-1)
   {
    //move up
       if(focusIndex>=0)
       {
        focusIndex = focusIndex-1;
         f = getField(focusIndex);
         f.setFocus();      
       }
   }
   if(amount==1)
   {
    //moving down
        if(focusIndex<=3)
        {
           f = getField(++focusIndex);
           f.setFocus();
        }
   }
     }
 return super.trackwheelRoll(amount, status, time);
}

even after this control moves abruptly on simulator but on device no change took place

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about curve