10-19-2012 02:55 AM - edited 10-19-2012 02:56 AM
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
setStatus(footerStatus(getButtonBar()));
...
public Field getButtonBar(){
HorizontalFieldManager hfm1 = new HorizontalFieldManager(USE_ALL_WIDTH|Manager.NO_HO RIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR);
backButton.setMargin(DeviceManager.getBackButtonTo pMargin(),0,0,DeviceManager.getBackButtonLeftMargi n());
nextButton.setMargin(DeviceManager.getNextButtonTo pMargin(),0,0,DeviceManager.getNextButtonLeftMargi n(nextBtnLeftMargin));
hfm1.add(backButton);
hfm1.add(nextButton);
return hfm1;
}
...
public Field footerStatus(Field button) {
Bitmap bm = Bitmap.getBitmapResource("img/footer.PNG");
HorizontalFieldManager hfm0 = new HorizontalFieldManager(USE_ALL_WIDTH|Manager.NO_HO RIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR);
Background bg = BackgroundFactory.createBitmapBackground(bm, Background.POSITION_X_LEFT, Background.POSITION_Y_BOTTOM, Background.REPEAT_SCALE_TO_FIT);
hfm0.setBackground(bg);
hfm0.add(button);
return hfm0;
}
Solved! Go to Solution.
10-27-2012 05:52 PM
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;
}
10-29-2012 01:35 AM
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 ![]()