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
Contributor
cyork2
Posts: 34
Registered: ‎02-28-2010
My Device: 8800
My Carrier: at&t
Accepted Solution

Radio button focus (should be simple)

When you have radio buttons and a radio button group do you have to set the radio button as FOCUSABLE or do something else to make  myradiobutton.isFocus()   work?  I am trying to test for focus in navigationclick but I'm not ever seeing the radio button with focus - even though it is highlighted and if I hit enter it is activated. 

 

I am in a popup window.  I am developing for 4.2.  Right below the Radio buttons is an objectlistfield and that field always has the focus even though the radio button will be highlited and functional if I hit the enter key.  It is almost like the radio buttons are on top of the objectlistfield or something but I haven't done anything fancy to try and put them on top of one another and if the list is empty I'm not seeing the "*empty*" text being on top of the radio buttons or vice versa.

 

 

//The radio definitions
RadioButtonField radio1, radio2;   
RadioButtonGroup rgrp;

//The radio group and button creation
rgrp = new RadioButtonGroup();
radio1 = new RadioButtonField("Phone", rgrp, !saveToSD);
radio2 = new RadioButtonField("SD", rgrp, saveToSD);

radio1.setChangeListener((FieldChangeListener) this);
radio2.setChangeListener((FieldChangeListener) this);

// Where I am testing for navigationclick
protected boolean navigationClick(int status, int time) 
{
  if( radio1.isFocus() || radio2.isFocus())
  {
     super.navigationClick(status, time);
     return true;
  }
  
  -- if radio buttons don't have focus the next section of code will get the objectlistfield selection and take action --

 

Am I missing something simple (like a spot to put the word FOCUSABLE)?

 

Thanks,
Craig York

 

 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Radio button focus (should be simple)

When you call getFieldWithFocus(), which field is returned?

 

Are all of the fields in the same manager?

 

What is the reason behind using navigationClick() the way you are? Do you know that you are 'eating" the click when the radio buttons have focus, and therefore probably keeping the buttons from getting checked? Is that your intention?

 

 

Please use plain text.
Contributor
cyork2
Posts: 34
Registered: ‎02-28-2010
My Device: 8800
My Carrier: at&t

Re: Radio button focus (should be simple)

I'm not "eating" the navigation click since I call  super  but yes I do understand what you are saying.

 

The only reason I bothered with processing   navigationclick   is the objectlistfield didn't seem to consume a trackball click and I wanted it to.  So if there is a way to make the objectlistfield consume the click that would be the better solution and I can stop processing clicks in my own code.

 

The only items on the screen are 2 radio buttons for selecting phone memory vs SD card and the objectlistfield which lists files in a specific path on whichever media you select.  You click a file name and it loads that file.

 

Here is what happens... you use the trackball to move to the SD card radio button.  You click the trackball.  You are not on the objectlistfield and have never been on the object list field.  if I check radio.isFocus I get false.  If I check objectlistfield.isFocus I get true.

 

thanks for trying to help.

Craig

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Radio button focus (should be simple)

I see what you are saying about navigationClick()

 

Instead of this:

 

 super.navigationClick(status, time);
 return true;

 

 

I would have done this:

 

return super.navigationClick(status, time);

Does the radio button "select" when you click on it?

 

Have you tried getFieldWithFocus() in your navigationClick() method?

 

Please use plain text.
Contributor
cyork2
Posts: 34
Registered: ‎02-28-2010
My Device: 8800
My Carrier: at&t

Re: Radio button focus (should be simple)

Thanks Rex - you put me on the right track and I hacked together something that works..

 

Details:

 

getFieldWithFocus returns the VerticalFieldManager - not very helpful 

getLeafFieldWithFocus  returns the field I actually want

 

After several trial and effort iterations I finally just changed my code to this:

 

Field tmpfield = getFieldWithFocus();
Field tmpfield2 = tmpfield.getLeafFieldWithFocus();

if(tmpfield2 != fileList)
{
   return super.navigationClick(status, time);
}

// fileList is my objectlistfield so if I am not processing that just let super handle this navigationclick

 

 

Note I also am now using your return super.... instead of calling super and returning true - that makes a lot more sense.

 

Thank you VERY VERY much for sending me down this path.

Regards,
Craig York

 

Please use plain text.