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
New Developer
Posts: 1
Registered: ‎04-27-2009
My Device: Not Specified

Missing Button Events on Storm

[ Edited ]

Have put 2 ButtonFields into a HorizontalFieldManager and am repositioning this on the screen using sublayout override.  Buttons respond to scrolling, and enter key press, but one of them is not responding to screen touch.   The other button responds correctly.  Problem goes away in the containing HorizontalFieldManager is not re-positioned, or if the button's preferred width is set to be a large value (eg. > 50 pixels).  From what I can tell, setPositionChild is causing the problem - but I can't understand why.

Has anyone seen this before?  I am including code just in case there is something really basic I am missing.

 

Thanks

 

 

 

public class TestScreen extends MainScreen {

   
    ButtonField aBut1 = new ButtonField("<",  ButtonField.CONSUME_CLICK);
    
ButtonField aBut3 = new ButtonField(">",  ButtonField.CONSUME_CLICK );
       

    public TestScreen() {

  
        VerticalFieldManager vfm = new VerticalFieldManager(NO_HORIZONTAL_SCROLL |
                NO_VERTICAL_SCROLL | USE_ALL_HEIGHT | USE_ALL_HEIGHT) {

         
            protected void sublayout(int maxWidth, int maxHeight) {

                super.sublayout(Display.getWidth(), Display.getHeight());

                int iCount = getFieldCount();

                for (int i = 0; i < iCount; i++) {

                    Field aField = getField(i);

                    layoutChild(aField, maxWidth, Display.getHeight());

                    if (aField instanceof HorizontalFieldManager) {  // reposition hfm

                          setPositionChild(aField, (Display.getWidth() - aField.getWidth()) / 2, Display.getHeight() /2 );        
                    }
                }
                setExtent(Display.getWidth(), Display.getHeight());
            }
        };

 

        HorizontalFieldManager hfmButt = new HorizontalFieldManager();

        LabelField label = new LabelField("label text");


        aBut1.setChangeListener(choseListener);
        aBut3.setChangeListener(choseListener);

 

        hfmButt.add(aBut1);
        hfmButt.add(label);
        hfmButt.add(aBut3);

 

        vfm.add(hfmButt);

        add(vfm);
    }

 

    FieldChangeListener choseListener = new FieldChangeListener() {

        public void fieldChanged(Field field, int context) {

          DoSomething();

        }
    };

Message Edited by Image9 on 04-27-2009 12:37 AM
BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Missing Button Events on Storm

The "touch sensitve" areas within the HorizontalFieldManager seem to be cut off at the half way point.  If you make the LabelField focusable, you'll also see that only the left half of it responds to the touch event.  I have sent this issue to our development team.
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