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: 96
Registered: ‎03-06-2009
My Device: Not Specified
Accepted Solution

Cannot get focus inside a HorizontalFieldManager

Hello,

 

I have several HFM in one VFM.

Each HFM contains one RichTextField. What I want to do is make a button appear near the RichTextField in the HFM everytime a row is "focused" (i.e. when the cursor is on one line) and make it disapear when I change row (to make it appear on the other row.

 

What I do is this:

 

HorizontalFieldManager row = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH) { protected void onUnfocus() { this.deleteRange(1, 1); } protected void onFocus(int direction) { ButtonField getDetailsButton = new ButtonField("See details", Field.FOCUSABLE); this.add(getDetailsButton); }; RichTextField cNameLabel = new RichTextField("test", Field.FOCUSABLE | Field.FIELD_VCENTER | RichTextField.USE_TEXT_WIDTH); row.add(cNameLabel); this.vfm.add(row);

 

 I do get the visual effect I wanted (the button appears on the line when I focus it and dispear when I leave it) but the problem is I cannot get the focus on my button or on the textfield. There is no cursor. And if I try to do it programatically (mybutton.setFocus() in the OnFocus() function) I get a nullpointerexception.

 

Any idea whats wrong? thanks 

 

Developer
Posts: 174
Registered: ‎08-20-2008
My Device: Not Specified

Re: Cannot get focus inside a HorizontalFieldManager

As far as I know you can not focus on a field which is managed by field which is focusable. An easier way to do this may be with a focusable nullfield within your HFM and use that instead.
Highlighted
Developer
Posts: 96
Registered: ‎03-06-2009
My Device: Not Specified

Re: Cannot get focus inside a HorizontalFieldManager

Cool it worked!

thanks