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 Contributor
Posts: 2
Registered: ‎10-01-2012
My Device: Bold 9900
My Carrier: Vodacom
Accepted Solution

Blackberry 9900 touch event not firing

Hey,

 

I'm new to BlackBerry development and need some help. I'm using a BlackBerry 9900 to test.

I have one screen in my application that has several buttons. It only responds to touch events if the button is highlighted.

Below is my code:

HorizontalFieldManager hfmRow = new HorizontalFieldManager();

_firstButton = new ButtonField("First");
_secondButton = new ButtonField("Second");
_thirdButton = new ButtonField("Third");
_fourthButton = new ButtonField("Fourth");
_fifthButton = new ButtonField("Fifth");	
	
hfmRow.add(_firstButton);
hfmRow.add(_secondButton);
hfmRow.add(_thirdButton);
hfmRow.add(_fourthButton);
		
add(hfmRow);
add(_fifthRow);

 

Developer
Posts: 121
Registered: ‎05-31-2012
My Device: 9900
My Carrier: Airtel

Re: Blackberry 9900 touch event not firing

[ Edited ]

try the following---------replace // Do Processing with what u want on Click

 

 

_firstButton = new ButtonField("First");
_secondButton = new ButtonField("Second");
_thirdButton = new ButtonField("Third");
_fourthButton = new ButtonField("Fourth");
_fifthButton = new ButtonField("Fifth");

HorizontalFieldManager hfmRow = new HorizontalFieldManager(){
protected boolean touchEvent(TouchEvent message) {
        int x = message.getX(1);
        int y = message.getY(1);
if (_firstButton.getExtent().contains(x, y)) {
          //Do processing
          return true;
}else if (_secondButton.getExtent().contains(x, y)) {
          //Do processing
          return true;
}else if (_thirdButton.getExtent().contains(x, y)) {
          //Do processing
          return true;
}else if (_fourthButton.getExtent().contains(x, y)) {
          //Do processing
          return true;
}else if (_fifthButton.getExtent().contains(x, y)) {
          //Do processing
          return true;
}else{
return super.touchEvent(message);
}
}
};
hfmRow.add(_firstButton);
hfmRow.add(_secondButton);
hfmRow.add(_thirdButton);
hfmRow.add(_fourthButton);
hfmRow.add(_fifthButton);
add(hfmRow);
add(_fifthRow);

 

 

 

Rishikesh Singh
New Contributor
Posts: 2
Registered: ‎10-01-2012
My Device: Bold 9900
My Carrier: Vodacom

Re: Blackberry 9900 touch event not firing

 Thank you very much, It worked very well

Developer
Posts: 121
Registered: ‎05-31-2012
My Device: 9900
My Carrier: Airtel

Re: Blackberry 9900 touch event not firing

ok, fine..

Happy Developing !!

Rishikesh Singh