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

Posts: 18
Registered: ‎03-11-2009
My Device: 9530 Simulator
Accepted Solution

HorizontalFieldManager button focus issue on Storm

I have data mined these forums looking for a solution but have found nothing.  The application I am creating has a title bar with 3 fields--previous button, label, next button.  Very simple and the layout works fine.  In the storm simulator you cannot set focus to the right button.  You can use the keyboard to navigate to it and click with return.  But touches do not work on this button.  If I change the center field to be a button it works for the center button.  Never for the right button.  I think it's a bug but if you know a work around please let me know.  Here is the code:



  // create previous button, current label, next button
ButtonField prev = new ButtonField("Prev", ButtonField.FOCUSABLE | ButtonField.CONSUME_CLICK);
_label = new LabelField("My Label", Field.FIELD_HCENTER);
ButtonField next = new ButtonField("Next", ButtonField.FOCUSABLE | ButtonField.CONSUME_CLICK);


HorizontalFieldManager header = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH)//HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.NO_HORIZONTAL_SCROLL)//HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.HORIZONTAL_SCROLL | HorizontalFieldManager.HORIZONTAL_SCROLLBAR | HorizontalFieldManager.RIGHTWARD)// | HorizontalFieldManager.NO_HORIZONTAL_SCROLL) { public int getPreferredWidth() { return Display.getWidth(); } protected void sublayout( int width, int height ) { super.sublayout( width, height ); width = getWidth(); height = getHeight(); Field leftField = getField(0); if (leftField != null && equals(leftField.getManager())) { setPositionChild( leftField, 0, 0); } Field centerField = getField(1); if (centerField != null && equals(centerField.getManager())) { int w = (width - centerField.getWidth()) / 2; int h = (height - centerField.getHeight()) / 2; setPositionChild( centerField, w, h); } Field rightField = getField(2); if (rightField != null && equals(rightField.getManager())) { setPositionChild( rightField, width - rightField.getWidth(), 0); } } }; header.add(prev); header.add(_label); header.add(next); setTitle(header);



Posts: 18
Registered: ‎03-11-2009
My Device: 9530 Simulator

Re: HorizontalFieldManager button focus issue on Storm



Basically my manager should not call super, needs to call layoutChild prior to setting position, and then setting the extent of manager.  Yeah lots of issues and sadly lots of sample code on this site does this.  Please refer to this page on how custom managers should be written: