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
Highlighted
New Developer
Posts: 4
Registered: ‎08-22-2009
My Device: Not Specified

Unable to get Focused field in Grid Manager

Using a GridFieldManager and getFieldWithFocusIndex I am trying to programmatically change the selected image when on focus - in essence a rollover image .. the problem is that the index I am getting is always returning -1 (meaning it has no focus) .. any ideas?

 

Here is the code for the function:

 

private BitmapField getBitmapField( String fileName ) { BitmapField result = new LabelledBitmapField( Bitmap.getBitmapResource( fileName ), Field.FOCUSABLE, "" ) { protected void onUnfocus() { String ImagesNormal[] = {"diamond.png", "crown.png", "heart.png", "spade.png", "anchor.png","club.png"}; int position = _gridManager.getFieldWithFocusIndex(); Bitmap hover; hover = Bitmap.getBitmapResource(ImagesNormal[0]); this.setBitmap(hover); //super.onUnfocus(); invalidate(); } protected void onFocus(int direction) { super.onFocus(direction); String ImagesHover[] = {"diamond_hover.png", "crown_hover.png", "heart_hover.png", "spade_hover.png", "anchor_hover.png","club_hover.png"}; int position = _gridManager.getFieldWithFocusIndex(); Dialog.alert(" " + position); Bitmap hover; hover = Bitmap.getBitmapResource(ImagesHover[0]); this.setBitmap(hover); invalidate(); } }; return result; }

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Unable to get Focused field in Grid Manager

What type of manager is _gridManager?  Is it a custom manager you have created?  Has the BitmapField been added to the _gridManager or are you nesting managers?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker