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
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: Select entire row of table format display

Sorry I wasn't sure how experienced you were from your post.

 

You can't set Focus on multiple Fields at the same time.  The only thing you can do is change the Fields so that they look like they have focus.  For example, you could set the background of a group of related Fields to the same color when one of them gets focus.  That is pretty much what you are going to to have to do with all the Fields in your TableLayoutManager row.  For example, you could have only one of the columns focusable, and in the 'onFocus() processing for this, set something in all the Fields in the same row that causes them to change visible state in a way that the user interprets as in focus. 

 

Does this make sense.

 

I don't think there is any other way. 

Please use plain text.
Contributor
souravbasu2k
Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: Select entire row of table format display

[ Edited ]

I've added two menu items, one for "Delete" and the other to "View" details about the row.

 

How do I retrieve the ID of the row which has the focus? I want to implement my delete() & view() operations based on that.

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: Select entire row of table format display

When I am doing context sensitive menu items, I typically use

 

Screen.getLeafFieldWithFocus()

 

and work it out from there.  So whatever Field is focusable in your Row will have some indication as to which row it is, or perhaps you can figure it out from its index in TableLayoutManager. 

 

Does that help?

Please use plain text.
Contributor
souravbasu2k
Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: Select entire row of table format display

[ Edited ]

Here is my skeletal code:

 

TableLayoutManager testTable = new TableLayoutManager(new int[]
 {
       TableLayoutManager. USE_PREFERRED_SIZE,
       TableLayoutManager. USE_PREFERRED_SIZE,
       TableLayoutManager.USE_PREFERRED_SIZE
  }, Manager.USE_ALL_WIDTH);

 

for (int i =0; i < 10; i++) {    

 

    Bitmap logoBitmap = Bitmap.getBitmapResource("res/link_icon.png");      
    BitmapField bitmapField = new BitmapField(logoBitmap, Field.FOCUSABLE);

    testTable.add(bitmapField);

 

    LabelField labelField1 = new LabelField("test label 1");

    testTable.add(labelField1);

 

    LabelField labelField2 = new LabelField("test label 2");

    testTable.add(labelField2);

 

}

 

super.add(testTable);

 

------------------------------------

 

How do I setup onFocus() processing for the "bitmapField", so that the entire row gets highlighted in Blue, when this field receives focus?

 

P.S : I got your basic idea but was unable to implement it in code.

 

 

Thanks

 

 

 

 

 

 

Please use plain text.
Contributor
souravbasu2k
Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: Select entire row of table format display

Can some body please tell me if this is at all possible in this way? If not, is there an alternative way in which I can achieve this same look and feel (Basically I am trying to create a screen which looks like the BlackBerry email listing)

 

Thanks.

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: Select entire row of table format display

Should be possible.  Wait for North America to come online and see if anyone there can help. 

 

However if you have as many entries to display as a typical email list, then I suspect this is going to be very slow on device. 

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: Select entire row of table format display

I had a look at TablelayoutManager with the intention of doing something like the sample I show below, but changing it looked like a nightmare.  So I bottled it.  Sorry.  Here is a simple implementation that does indicate an entire row is in focus, but this uses hfm to manage a row. 

 

Here is the replacement sketetal code:

 

for (int i =0; i < 10; i++) {   
    FocusIndicatingHorizontalFieldManager fihfm = new FocusIndicatingHorizontalFieldManager();
    Bitmap logoBitmap = Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION);     
    BitmapField bitmapField = new BitmapField(logoBitmap, Field.FOCUSABLE);
    fihfm.add(bitmapField);
    LabelField labelField1 = new LabelField("test label 1");
    fihfm.add(labelField1);
    LabelField labelField2 = new LabelField("test label 2");
    fihfm.add(labelField2);
    tab3Manager.add(fihfm);
}

 

And here is the focus indicting HFM:

 

class FocusIndicatingHorizontalFieldManager extends HorizontalFieldManager {
    boolean _inFocus = false;
    public FocusIndicatingHorizontalFieldManager() {
        super();
    }
    protected void onFocus(int direction) {
        super.onFocus(direction);
        _inFocus = true;
        super.invalidate();
    }
    protected void onUnfocus() {
        super.onUnfocus();
        _inFocus = false;
        super.invalidate();
    }
    public void paint(Graphics graphics) {
        int stipple = graphics.getStipple();
        super.paint(graphics);
        if ( _inFocus ) {
            graphics.setStipple(0xFFFFFFFF);
        } else {
            graphics.setStipple(0x22222222);
        }
        graphics.drawRect(0,0, this.getWidth(), this.getHeight());
        graphics.setStipple(stipple);
    }
}

Please use plain text.
Contributor
souravbasu2k
Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: Select entire row of table format display

Thanks for the help. Your code does fulfill my requirements!

 

The only thing I'd like to have is to set the background color of the row having the focus to to blue. I tried to change:

 

graphics.setStipple(0xFFFFFFFF);

to

graphics.setBackgroundColor(0x185AB5);

 

inside the paint() method. However it's not working. Any thoughts ?

 

 

Thanks

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: Select entire row of table format display

after a setBackgroundColor you should do a

 

graphics.clear().

 

I was going to change my code to do that, but I had the stipple code there and working so I was just being lazy.....

Please use plain text.
Contributor
souravbasu2k
Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: Select entire row of table format display

Now, it is working perfectly. Many Thanks!

 

 

Please use plain text.