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
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

how to restrict track ball scrolling

Hi all,

I have made a home screen it contains 9 icons. so while trackball scrolling,if the user scroll a bit faster then the focus shifted from first to any icon. But user want the focus to shift on the next icon only.

I have implemented trackballroll(amount,status,time). but still the user can roll more than one amount on 1 roll.

public boolean trackwheelRoll(int amount, int status, int time)
    {
       
  
        Field f = this.getLeafFieldWithFocus();
        if(amount > 0)
        {
            try{
                    for(int i =0; i < 9; i++)
                    {
                        if( f == btmIcons[i])
                        {
                            if(f == btmIcons[8])
                                break;
                            else
                            {   
                                btmIcons[++i].setFocus();
                                break;
                            }
                        }
                    }
                }
                catch(Exception e)
                {
                    System.out.println("Exceptionnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn "+e.toString());
                }
        }
        else
        {
            // Action to perform if trackwheel is rolled down.
            for(int i =0; i < 9; i++)
            {
                if( f == btmIcons[i])
                {
                    if(f == btmIcons[0])
                                break;
                    else
                    {
                        btmIcons[--i].setFocus();
                        break;
                    }
                }
            }
           
        }
        return true; 
    } 

 

 

i implemented nextFocus but it never called.

 

Please tell me that is there any other function which can solve my issue? I have read about setTrackBallFilter() and TrackBallSensitivity(), but i have not tried.so please tell me that these method are helpfull in this issue ?

 

Thanks and Regards,

Mudassir

Thanks and Regards
Please use plain text.
Developer
simon_hain
Posts: 16,093
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how to restrict track ball scrolling

the correct method to handle focus movement is moveFocus
try this code:

protected int moveFocus(int amount, int status, int time) {
if (amount > 0) {
amount = 1;
}
if (amount 0) {
amount = -1;
}
return super.moveFocus(amount, status, time);
}
}
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

Re: how to restrict track ball scrolling

Hi,

i forget to mention that i also used moveFocus(amount,status,time) but even it is not been called during runtime.

Is there any more way to implement it ?

 

Thanks

Thanks and Regards
Please use plain text.
Developer
simon_hain
Posts: 16,093
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how to restrict track ball scrolling

i just saw that you use trackballroll, try to use navigationmovement instead.
did you try to limit the amount there?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

Re: how to restrict track ball scrolling

yes i implemented

 

public boolean trackwheelRoll(int amount, int status, int time)
    {
        if (amount > 0)
        {
            amount = 1;
        }
        if (amount < 0)
        {
            amount = -1;
        }
        return super.trackwheelRoll(amount,status,time);
    }
   
    protected boolean navigationMovement(int dx,int dy,int status,int time)
    {
        if(dx < 0)
        {
            dx = -1;
        }
        if(dx > 0)
        {
            dx = 1;
        }
        if(dy < 0)
        {
            dy = -1;
        }
        if(dy > 0)
        {
            dy = 1;
        }
        return super.navigationMovement(dx,dy,status,time);
    }

 

Both methods are been called. but actually what i want to do is that i want to shift focus to next field only,inspite of how much amount user roll track ball.

 

Thanks

Thanks and Regards
Please use plain text.
Developer
simon_hain
Posts: 16,093
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how to restrict track ball scrolling

if you consume navigationmovement by returning true you should have no navigation at all.
now you can focus whatever field you want based on dx/dy.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

Re: how to restrict track ball scrolling

Hi,

when i scroll my home page with simulator(i.e with help of mouse) , it scrolls very fast . i implemented trackball event(trackballroll() and navigationmovement()) but then also it is scrolling very fast. and the focus jumps over many icons.

So,please tell me that mouse scrolling on trackball of simulator is having a different behaiiour from track ball functioning ?

 And how i can i test the proper functioning of track ball roll ? 

And how can i restrict the trackball rolling to more than one amount,so that focus gets only on next item,and it doesnt jump over other ?

 

Thanks and Regards,

Mudassir

Thanks and Regards
Please use plain text.
New Developer
New Developer
sa
Posts: 8
Registered: ‎10-20-2008
My Device: Not Specified

Re: how to restrict track ball scrolling

Hi, i think there are some problems on your application but;

 

if you want to guarentee that the focus can not be set in x milliseconds after a focusChanged, you can implement navigationmovement like that;

 

private int FOCUS_PERIOD = 200;//millisecond

private int lastFocusChangedTime = 0;

 

protected boolean navigationmovement(int dx, int dy, int status, int time)

{

if((time - lastFocusChangedTime) >= FOCUS_PERIOD)  

{

lastFocusChangedTime = time;

//Whatever you want to do

}


return true;

 

}

 

 

Please use plain text.