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
Highlighted
Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Problem with touchEvent and click

HI all,

 

I have a strange problem. I have a screen with 2 fields, a field at top and a field at bottom.

 

The default focus is set to the top field. 

 

Now when I click in middle of the screen the event on the top field is executing and the screen is pushing to the next screen.

 

When I debug, I found that the touch event is firing when I clik on middle of the screen, under touchEvent(), TouchEvent.CLICK calls super.touchEvent  and it results to invoke the event on the top of the fields.

 

Both the fields are instances of custom buttonfields extended from field.

 

How can I fix this?

 

 

Thanks and Regards,
PraveenGoparaju.
Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Problem with touchEvent and click

any ideas??

Thanks and Regards,
PraveenGoparaju.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem with touchEvent and click

This has been reported before, as I understand it the 'problem' is that the touch event is passed to the Field that has focus.  You need to check the location of the event to make sure it is within your extent before processing it.  Normal buttons seem to do this. 

Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Problem with touchEvent and click

Yes, you are right. But how can I confirm whether the touch event is on valid location...? One alternative is using x, y positions from the touch event. Other than this... any ideas?

Thanks and Regards,
PraveenGoparaju.
Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Problem with touchEvent and click

What's wrong with checking the x, y positions?




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: Problem with touchEvent and click

Hi,

 

I am facing similar issue.

There are three CustomBasicEditFields aligned vertically with first one in focus.

When I click on any field using navigation click it all works fine as focus changes while selecting the field and

a popup screen opens correctly

 

But when I use touch event only the popup screen associated with first field opens for all three fields present.

How can I correct this "isFocus" issue in touch event and open correct popup?

 

I don't want use x-y coordinates !!!

I am using 9800 simulator.

 

Thanks

Abhinav Tyagi

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: Problem with touchEvent and click

Any idea?

I really need this to work!!!

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Problem with touchEvent and click

As far as I know there is no way to do it without checking the x,y coordinates. Why do you not want to use these values?

Developer
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
My Carrier: Airtel

Re: Problem with touchEvent and click

Can you tell me how can I use x,y coordinates to get to the selected editField?

I have a simple vertical field manager and three custome basiceditfields in it

 

I would be designing screen for different models and x,y coordinates will not be same for different

handsets. that is why I don't want to use this approach.

 

Thanks

Abhinav Tyagi

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Problem with touchEvent and click

You would use the x,y coordinates passed in the TouchEvent to see if they fall in a fields extent. The screen size does not matter since you will check each field to see if it lies within it's extent. I use all custom fields, so I can't show you exact code, but it would be of this nature:

 

if( TouchEvent.getX(1) > Field.getExtent().x && 
TouchEvent.getX(1) < (Field.getExtent().x+Field.getExtent().width) && TouchEvent.getY(1) > Field.getExtent().y &&
TouchEvent.getY(1) < (Field.getExtent().y+Field.getExtent().height) ){ //Field has been touched }