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
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified
Accepted Solution

How to highlight bitmapfield when focussed?

Hi

 

I am trying to create an image based menu for my App.

 

The idea is to display different image icons to the user. The user can scroll over these images and then select an icon by clicking on it.

 

i have started by displaying simple bitmaps using bitmapfield and then overriding the trackwheel click event. Here i check which bitmapfield has the focus and perform the next step accordingly.

 

Currently, i am unable to highlight any icon when the focus is on it or when it is selected. This makes it different to know which icon is currently in focus.

 

This is how i am declaring my bitmapfields:

 

bmpRecFld= new BitmapField(bmpRec,BitmapField.FOCUSABLE|BitmapField.HIGHLIGHT_FOCUS|BitmapField.HIGHLIGHT_SELECT);

Can someone please guide me here?

 

Thanks,

Saket

 

Regular Contributor
Posts: 71
Registered: ‎07-11-2010
My Device: Bold 9000
My Carrier: none

Re: How to highlight bitmapfield when focussed?

You can try extending BitmapField and overriding

 

protected void drawFocus(Graphics graphics,
boolean on)

 

You can also save some time if you use the search functionality to search this forum for similar questions (I have seen many in the past)


-----
A good decision is based on knowledge and not on numbers.
Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: How to highlight bitmapfield when focussed?

Do u want to show the blue focus color around the bitmap fields

if yes then

BitmapField  bitmapField = new BitmapField(bitmap,Field.FOCUSABLE){
           
protected void layout(int width, int height) {
                setExtent
(bitmap.getWidth()+10, bitmap.getHeight()+10);
           
}

       
};

else may b i dint understand

 

 

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: How to highlight bitmapfield when focussed?

Thanks Swati

 

This is pretty much what i am looking for. btw is it possible to change the colour of the highlight? say if i want to make it look a bit more glossy?

 

also how did u know this? can you please tell me where i can find the various methods like layout() which can be used to edit the behaviour/appearance of ui objects?

 

my app's ui looks very basic i and i want to make it more appealing, i am looking at building custom controls.....i would really appreciate if you could suggest some links for the same.

 

Thanks again!

Saket

 

Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: How to highlight bitmapfield when focussed?

well i got this result after lots of googling

 

if u want to make your app more appealing,try to make use of images instead of using existing controls

this will give ur app a good look.

 

Make images focusable and do what u want to do

Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: How to highlight bitmapfield when focussed?

hey i havent did changing the highlight color but m pretty sure it can be done

needs overriding

 

i will make research and do let u know if i get that

Highlighted
Developer
Posts: 64
Registered: ‎02-12-2011
My Device: 9300
My Carrier: Yoigo

Re: How to highlight bitmapfield when focussed?

Hi all. I know it is solved but I found another solution that I like more and I wanted to share it.

 

Instead of overwriting the layout method I simply used the setSpace method after declaring the field.

 

BitmapField bitmapField = new BitmapField(bitmap);
bitmapField.setSpace(10,10);

it adds a border to the BitmapField and it showed the focus on all borders. Overwriting layout only showed the focus on the bottom and right corners (because the bitmap was not drawn centered).