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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Contributor
Posts: 4
Registered: ‎08-29-2011
My Device: BlackBerry 9700 Bold
My Carrier: Airtel India
Accepted Solution

Two horizontal managers are scrolling in screen

[ Edited ]

Screen has two scrollable horizontal filed mangers with Manager.HORIZONTAL_SCROLL, while scrolling second manger once focus reached end of manger, automatically above manger items scrolling horizontally.

 

Example:

First manager has 10 items and below second manager has 10 items, first i do scroll down and focus will be on second manger first item, now i do right navigation once focus reached 10th item of second manager above manager items starts horizontal scroll.

 

This is happening on device and simulator also. i have tested on 5.0, 6.0 and 7.0 same issue is there.

 

Sample code sinppet:

 

HorizontalFieldManager hfmOuter = new HorizontalFieldManager(FOCUSABLE | Manager.HORIZONTAL_SCROLL);

for (int i = 0; i < 10; i++) {
hfmOuter.add(new LabelField(" TITLE "+i, FOCUSABLE));
}
add(hfmOuter);

HorizontalFieldManager hfmOuter1 = new HorizontalFieldManager(FOCUSABLE | Manager.HORIZONTAL_SCROLL);

for (int i = 0; i < 10; i++) {
hfmOuter1.add(new LabelField("NAME"+i, FOCUSABLE));
}
add(hfmOuter1);

 

 

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Two horizontal managers are scrolling in screen

welcome to the support forums.

please take a look at http://supportforums.blackberry.com/t5/Java-Development/HorizontalField-scrolling-issue/td-p/2193537
this seems to be the exact same issue.
----------------------------------------------------------
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
New Contributor
Posts: 4
Registered: ‎08-29-2011
My Device: BlackBerry 9700 Bold
My Carrier: Airtel India

Re: Two horizontal managers are scrolling in screen

Yes! its same issue, but simply if we overridden movefocus and navigationMovement methods also no change in behaviour. still issue exists.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Two horizontal managers are scrolling in screen

If I understand this problem correctly, there are two potential issues:

 

a) When scrolling horizontally from the second manager you do not want focus to leave that Manager - instead you want the scrolling to stop.

 

Here is some code to do that:

 

        protected boolean navigationMovement(int dx, int dy, int status, int time) {
                int focusIndex = getFieldWithFocusIndex();
                if ( focusIndex == 0 && dx < 0 && dy == 0 ) {
                        // scrolling left but at beginning
                        return true;
                }
                if ( focusIndex == this.getFieldCount() - 1 && dx > 0 && dy == 0 ) {
                        // scrolling right but at end
                        return true;
                }
                return super.navigationMovement(dx, dy, status, time);
        }

 

The second potential problem is that you don't want the scroll to start at the 'end' of the first Manager, instead you want focus to return to the currently selected item from the first HFM.  This is a more complicated problem - you need to retain an indication of which Field this was (let us call it the selected Field) and when focus returns to the Manager, set Focus on the selected entry. 

 

Assuming you retain this selected indicator, then you override onFocus to set the focus back to the selected item, code would look something like this:

        protected void onFocus(int direction) {
            if ( direction != 0 && currentlySelectedField != null ) {
                UiApplication.getUiApplication().invokeLater(new Runnable() {
                    public void run() {
                    	try {
                    	    currentlySelectedField ();
                    	} catch (Throwable t) {
                    	    LibraryRepository.logEventError("GalleryVoucher Focus problem: " + t.toString());
                    	}
                    }
                });
            } else {
                super.onFocus(direction);
            }
        }

 

 

New Contributor
Posts: 4
Registered: ‎08-29-2011
My Device: BlackBerry 9700 Bold
My Carrier: Airtel India

Re: Two horizontal managers are scrolling in screen

Thank You,

First solutions worked using navigationMovement.