BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-16-2007, 07:27 AM   #1 (permalink)
New Member
 
Join Date: Feb 2007
Location: ISrela
Model: 8700
Carrier: Orange IL
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Scrollingf issue - help

Please Login to Remove!

Hi all,
I have a VerticalFieldManager which contains a lot of fields. I want the manager to scroll a certain ammount of fields in response to user events. For example , hit space will scroll 10 rows. I can't use the EventInjector API because it's security policy default is 'Disallowed'. I'm trying to override moveFocus and nextFocus but no luck ? Any Ideas ?

Thanks a lot,
Idan.
Offline  
Old 02-16-2007, 09:09 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

One way to do this is to implement the keyChar method from the screen classes and in the case of Characters.SPACE, force a trackwheelroll method call passing it 10 (or whatever number) as the amount parameter. The manager will handle the scroll from there.
Offline  
Old 02-16-2007, 10:26 AM   #3 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

that sounds interesting, would it smoothly scroll to the new index rather than just jumping? sounds like a nice little hack, anyone care to post a snippet of it in action?
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 02-16-2007, 11:18 AM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

it would jump in the same manner that holding down the alt key signals to the method through the status parameter that it should jump. If you wanted to emulate a smooth scroll you could loop through forcing the trackwheelRoll method just incrementing by one

something as simple as this (untested) *should* work when implemented inside a class that extends Screen or it's derivitaves
Code:
public boolean keyChar(char key, int status, int time) {
	
		switch (key) {
		case Characters.SPACE:
                trackwheelRoll(10,0,0);
break;
return true;
}
Offline  
Old 02-16-2007, 06:37 PM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Jan 2007
Model: 8100
Carrier: Rogers
Posts: 22
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you could use a timer to scroll smoothly if what was suggested doesnt.
Offline  
Old 02-16-2007, 07:13 PM   #6 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is interesting stuff, i'll try and implement something after the weekend, looking forward to trying it.
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 02-17-2007, 03:52 AM   #7 (permalink)
New Member
 
Join Date: Feb 2007
Location: ISrela
Model: 8700
Carrier: Orange IL
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default scrolling reply

Thanks bemshaswing , your sujesstion worked perfectlly. Don't know why I didn't look for the simple way...
Offline  
Old 02-18-2007, 11:37 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Oct 2006
Model: 8707g
Carrier: Hutch
Posts: 73
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you try field.setFocus() ?
I assume you can find out what field you want to set focus to.

You can also try calling moveFocus(10, status, time) in the keyChar method, instead of trying to override it.
Offline  
Old 02-20-2007, 03:22 AM   #9 (permalink)
New Member
 
Join Date: Feb 2007
Model: 7290
Carrier: TMobile
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use the protected methods setHorizontalScroll and setVerticalScroll of a Manager to achieve pixel-wise animated scrolling.

But the trick is that these methods are supposed to be called from the framework and will only update the screen's paint buffer and will not be visible unless you manually update the paint buffer to the screen using UiApplication.getUiApplication().updateDisplay();

So you could use something like

_manager.setVerticalScroll(_manager.getVerticalScr oll()+5);

called from a public method of a Field, called from a TimerTask.

Also, because the methods are protected, and you want to call them from the outside (i.e. from a TimerTask) you have to write a public method in your field that uses them.

Also, if the user moves the area of focus area outside the current area visible by the scroll value, the scroll value will automatically be adjusted by the framework. If you want the scroll value to be independent from the focus area, you have to "fake" the focus rect to always be inside the scroll area (i just return a rect with x and y at getHorizontalScroll() and getVerticalScroll() and width and height of 1)

Also note that the fields should be enveloped inside Managers that are scrollable and you have to correct the scroll value when the manager loses focus (as the framework automatically sets it to the top or bottom of the field) so you have to do this inside moveFocus() of the manager:

Code:
        protected int moveFocus(int amount, int status, int time)
        {
            //System.out.println("Manager moveFocus ("+amount+") - start");
            
            int scroll=getHorizontalScroll();
            int retValue;
            
            retValue = super.moveFocus(amount, status, time);
            
            //correct any automatic change of horizontal scroll
            
            if (getHorizontalScroll()!=scroll)
            {
                System.out.println("Correcting scroll change ");
                setHorizontalScroll(scroll);
            }
            
            //System.out.println("Manager moveFocus - end ("+retValue+")");
            
            return retValue;
        }

I did a whole Animator/Animated framework for animation of scrolled BB UI fields with a single TimerTask that calls all animated fields and does a single call to updateDisplay at the end of them all if it is necessary (indicated by return flags of the animate() methods of the animated fields, for the application i'm developing....

Last edited by dane : 02-20-2007 at 03:40 AM.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.