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: 13
Registered: ‎10-04-2012
My Device: BlackBerry 9930
My Carrier: RIM
Accepted Solution

How to avoid HorizontalFieldManager from being clicked

[ Edited ]

I have added a footer image on my setStatus() and over that image I have used a HorizontalFieldManager that contains two buttons.


When I click on the footer image the button is clicked I don't understand why. Please help.


Here's the code:


//In my main screen



public Field getButtonBar(){
HorizontalFieldManager hfm1 = new HorizontalFieldManager(USE_ALL_WIDTH|Manager.NO_HORIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR);

    return hfm1;


public Field footerStatus(Field button) {
Bitmap bm = Bitmap.getBitmapResource("img/footer.PNG");

HorizontalFieldManager hfm0 = new HorizontalFieldManager(USE_ALL_WIDTH|Manager.NO_HORIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR);

Background bg = BackgroundFactory.createBitmapBackground(bm, Background.POSITION_X_LEFT, Background.POSITION_Y_BOTTOM, Background.REPEAT_SCALE_TO_FIT);
    return hfm0;


Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to avoid HorizontalFieldManager from being clicked

When you touch a place on the screen, the system will look for a focusable Field in the area that you touched and direct your click at that.  If it can't find this, it will direct the click to the Field in focus.  If you want to ignore these, you have to supress clicks when the initiating locaiton is outside your Field.  Here is some sample code:



int x = message.getX( 1 );

int y = message.getY( 1 );

if( x < 0 || y < 0 || x > getExtent().width || y > getExtent().height ) {      

// Outside the field

return false;


Posts: 13
Registered: ‎10-04-2012
My Device: BlackBerry 9930
My Carrier: RIM

Re: How to avoid HorizontalFieldManager from being clicked

Thanks Peter!

I simply did what you said. Overridden the touchEventmethod and within it called the method navigationClick on the following check(if it was false):

if( x < 0 || y < 0 || x > getExtent().width || y > getExtent().height ) 


It worked and I learnt something good. You're just a saviour Smiley Wink