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
New Developer
Posts: 5
Registered: ‎07-20-2008
My Device: Not Specified

Fixed Column Labels That Scroll Horizontally but not Vertically

[ Edited ]

Using 4.2.1 and have successfully setup a row label VerticalFieldManager and an associated grid with all scrolling working just as I want them to.  What I haven't been able to accomplish is having a vertically fixed title region that also scrolls horizontally with my grid (to allow "frozen" column labels to scroll with the data in the grid, as you scoll down it needs to remain fixed vertically but scroll horizontally.)  I've used setTitle to place the column label HorizontalFieldManager but haven't figured out how to get it to scroll horizonally in lockstep with the underlying data grid.  I've overridden HorizontalFieldManager as follows and use it exclusively in this class:

 

 

private class myHorizontalFieldManager extends HorizontalFieldManager implements ScrollChangeListener {
       
        protected void setHorizontalScroll2( int horizontalScroll ) {

            super.setHorizontalScroll( horizontalScroll );

        }
     
        public void setHorizontalScroll( int horizontalScroll ) {

// Attempts to break on this line do not occur when scrolling:

            setHorizontalScroll2( horizontalScroll );
        }

        public void scrollChanged(Manager manager, int newHorizontalScroll, int newVerticalScroll) {

// Attempts to break on this line do not occur when scrolling in the simulator

            manager.setHorizontalScroll(newHorizontalScroll);
       }

    }   

Field manager configuration-related code (my class extends MainScreen):


        VerticalManager1 = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Field.NON_FOCUSABLE){
                    protected void sublayout(int width, int height) {
                    super.sublayout(Display.getWidth()/3, height);
                }
        };
       
        VerticalManager2 = new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.HORIZONTAL_SCROLL){
                    protected void sublayout(int width, int height) {
                    super.sublayout((Display.getWidth()/3)*2, height);
                }
        };

        HorizontalManager1 = new myHorizontalFieldManager(){
                    protected void sublayout(int width, int height) {
                    super.sublayout(Display.getWidth()/3, height);
                }
        };
       
        HorizontalManager2 = new myHorizontalFieldManager(){
                    protected void sublayout(int width, int height) {
                    super.sublayout((Display.getWidth()/3)*2, height);
                }
        };

.
.
. 

       VerticalManager2.add(grid);

// placeholder for use in my title region for the row lable portion
       HorizontalManager3.add(HorizontalManager1);

// column labels to place in the title region
       HorizontalManager3.add(HorizontalManager2);

 

// I can add the column lables using setTitle but havent figured out how to get them to scroll horizontally in //lockstep
       setTitle(HorizontalManager3);

// VerticalManager1 contains the row lables, works perfectly (scrolls vertically but not horizontally)
       mainHorizontalManager.add(VerticalManager1);

// VerticalManager2 contains the data grid itself, all scrolling here works just as desired
       mainHorizontalManager.add(VerticalManager2);

       add(mainHorizontalManager);


this.setScrollListener(new ScrollChangeListener() { public void scrollChanged(Manager manager, int newHorizontalScroll, int newVerticalScroll) { // Attempts to break on this line do not occur when scrolling in the simulator setHorizontalScroll(newHorizontalScroll); } });

 

So I think my biggest challenge right now is just getting scroll actions to throw scollChange which I believe would give me the ability to call setHorizontalScroll for the column label myHorizontalManager object.  Any suggestions on what I'm missing are greatly appreciated.  Also if it is not possible to scroll horizontally within a title region that would be great to know before I head too much further down that path.