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
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Focus control is working properly on 8700 but not on 8100

[ Edited ]

os for 8100 is v4.2.0.61

and for 8700 is v4.1.0.194

 

My screen is displaying as

 

-----------------        E

-----------------    S  M

----------------         L

 

where

 ----- is LabelField  (non focusable)

E-email BItmapField 

S SMS BItmapField  

M Mobile BItmapField  

L Landline BItmapField  

 

I used 3 horizontal field managers.

Initial focus should be on E

 

I m expecting the focus after trackwheel scroll as

E --> S --> M --> L  and E <-- S <-- M <-- L

And the corresponding bitmaps should be change after getting or lossing focus

 

It's behaviour is exactly same as I expect on the devices other than 8100

 

and On 8100 when trackwheel is scrolled downword focus doesnt seem to be come on S bitmap field.

Next scroll of trackwheel causes to change bitmap on M but only half bitmap is drawn on it's proper position.

next scroll changes the bitmap for L but not at it's proper position. It displays 30 to 40 pixels up to it's origanal position(bitmapField).

 

Same case happens with upword scroll. The focused bitmap for E gets drawn at 30 to 40 pixels up to it's origanal position(bitmapField).

 

Is it too much confusing?......same problem with me also....though I am watching the screen :smileyhappy:

Message Edited by dhanashreerao on 10-16-2008 08:01 AM
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Focus control is working properly on 8700 but not on 8100

OK, there appear to be two problems here,

 

But first, for the 4.1 8700, you should develop in 4.1.  When 4,2 came out, a number of people converted their 8700 devices to bricks by installing 4.2 compiled applications on them.  This situation seems mostly related to start-up applications, i.e. applications that did some processing at start-up of the device.  These would fail and then the 8700 would be continually restarting.  Not good.  Don't do it.....

 

Anyway, the two problems:

1) The order that you are seeing focus move is the expected order.  On the Pearl, you are moving the track ball down when you are on S, so the HorizontalFieldManager assumes you want to go down to the next Manager.  To go from S to M (and back) you need to scroll left.

2) The incorrect drawing of the focused Bitmap.  I presume you have overridden layout or sublayout in the HoriizontalFieldManager to get the Buttons side by side?  There is a bug in there I suspect.

 

OK, what to do?

 

1) Review the following Thread, where another poster had a similar problem and resolved it.  However we have never got to the bottom on the magic numbers.... 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=4028

The question was asked again in this Thread...

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=6563&query.id=157...

 

2) I would try the fields outside of your HorizontalFieldManager and see if they work correctly.  Then check your code.  If you think your code is OK, then you are going to have to post it here so we can look at it.

 

Please use plain text.
Developer
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Focus control is working properly on 8700 but not on 8100

Thank you Peter,

 

Ur previous thread's solution worked for controling the focus. But Drawing bitmap problem still arrives.

I have not used layout or subLayout for horizontalFieldManager.

To set bitmapFields to their appropriate positions, I used  BitmapField.setSpace(int x, int y) method where x is number of pixels from left of the current position in HFM and y is number of pixels from top of the HFM.

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

Re: Focus control is working properly on 8700 but not on 8100

The test I did for you also used setSpace(..) and had no problems.

 

I few questions that will help us recreate your problem. 

 

Can you add the BitmapField directly to a MainScreen to see if the problem is still present?

Is this only on the device or can the problem be replicated on the simulator?

What size is the Bitmap you are displaying?

How do you create the Bitmap?

Please use plain text.
Developer
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Focus control is working properly on 8700 but not on 8100

I tried as per ur suggestion

 

When all bitmap fields are added on a main screen, the focus is working fine. But when I put all the bitmapfield in one vertical field manager togetherly, the same problem persists.

 

If I would directly set the bitmap fields on the main screen, then how can i set their positions?

 

All bitmaps used in my code are of size 22x20 pixels

 

and I m using the code for creating bitmap is

Bitmap bmpOnfocusEmail =       Bitmap.getBitmapResource(Utility.EMAIL_F);

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

Re: Focus control is working properly on 8700 but not on 8100

I've tried to recreate your problem without success.

 

Following you will find the code I've been trying.  You should be able to cut/paste it into your application.  Do you see a problem with this code?

 

I have this code in the constructor of the Screen.... HorizontalFieldManager hfm = new HorizontalFieldManager(); hfm.add(getBitmapField(Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION),Bitmap.getPredefinedBitmap(Bitmap.QUESTION))); hfm.add(getBitmapField(Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION),Bitmap.getPredefinedBitmap(Bitmap.QUESTION))); this.add(hfm); VerticalFieldManager vfm = new VerticalFieldManager(); vfm.add(getBitmapField(Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION),Bitmap.getPredefinedBitmap(Bitmap.QUESTION))); vfm.add(getBitmapField(Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION),Bitmap.getPredefinedBitmap(Bitmap.QUESTION))); this.add(vfm); Here is the getBitmapField() method, based loosely on what you supplied previously. /** * Description : this method creates bitmap field and controls it's focus property * @param bmpOffFocus : the bitmap drawn when bitmapField looses a focus * @param bmpOnFocus : the bitmap drawn when bitmapField gets a focus * @return BitmapField */ public BitmapField getBitmapField(final Bitmap bmpOffFocus, final Bitmap bmpOnFocus) { BitmapField objBmpBtn = new BitmapField(bmpOffFocus, BitmapField.FOCUSABLE) { boolean isFocus ; protected void onFocus(int arg0) { setBitmap(bmpOnFocus); invalidate(); } protected void onUnfocus() { setBitmap(bmpOffFocus); invalidate(); } protected void paint(Graphics graphics) { graphics.setBackgroundColor(0xDFBC7A); graphics.clear(); super.paint(graphics); } }; objBmpBtn.setSpace(5,5); return objBmpBtn; }

 

Please use plain text.
Developer
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Focus control is working properly on 8700 but not on 8100

Hi Peter,

I tried this code, but problem still persists.

And if I m creating the bitmapField without assigning it to an object variable (obj=getBitmapField(a,b)) then how can I handle trackwheel click event for those BitmapFields?

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

Re: Focus control is working properly on 8700 but not on 8100

So, can you confirm when you use the code I supplied, that you see a focus problem on the real device where the image gets drawn in the wrong place?

 

If so, then I think we need to report this.

 

I agree that my code did not correctly listen for click events, but that wasn't the point of the test, the point of my code was to demonstrate the focus was drawing the image badly.

Please use plain text.
Developer
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Focus control is working properly on 8700 but not on 8100

Today, just before 1hr, I checked the code u supplied.

 

When it was not causing any change, I did another experiment. And I got from where the exact problem is occuring.

 

I took one vertical FM, and added all the horizontal FMs as mensioned earlier. Upto this everything is as same as earlier.

Only I put comment to the overrided paint method of that main VFM on which all the horizontal field managers are residing. And the problem got solved. Focus control is working properly.

 

What is the meaning of this case? 

 

Please use plain text.
Developer
dhanashreerao
Posts: 51
Registered: ‎08-25-2008
My Device: Not Specified

Re: Focus control is working properly on 8700 but not on 8100

Hello All,

 

First, thanks lot Peter, you helped me constantly so I was able to think more for my problem.

 

The problem is solved now.

In my code, everything was fine. Only the mistake was, I was using graphics.translate(x,y) method in a paint method of VFM. When I removed it, the focus control started to work properly. And I achived what I want on the screen.

Please use plain text.