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
Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Touch event on various different OS versions and devices

HI,

 

I have implemented the generic application which supports 5.0 and 6.0 devices. Can I safely assume for the button click as TouchEvent.CLICK for all 5.0 touch devices and TouchEvent.UP for all 6.0 touch devices?

 

Thanks

Sandeep

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Touch event on various different OS versions and devices

just use a fieldchangelistener and CONSUME_CLICK on the button
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: Touch event on various different OS versions and devices

True. However I have some custom control where i need to handle the Touch/Click manually. I planning to check it using the following code.

 

String versionString = DeviceInfo.getSoftwareVersion();

if ( versionString.indexOf("5") == 0)

{

     if ( message.getEvent() == TouchEvent.CLICK)

     {

         // My own listener

         buttonListener.fieldChanged();

     }

}

 

if ( versionString.indexOf("6") == 0)

{

   if ( message.getEvent() == TouchEvent.UP)

   {

         buttonListener.fieldChanged();

   }

}

 

Hope it is fine.

 

 

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

Re: Touch event on various different OS versions and devices

Can I ask why you feel that either

 

1) TouchEvent.CLICK does not work in OS 6.0 or

2) TouchEvent.UP does not work in OS 5.0?

 

Also, have you thought about OS 7.0?

Highlighted
Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: Touch event on various different OS versions and devices

I dont have the Torch phone which has the 6.0 and touch. I tested this on a Torch simulator. As torch does not have physical click we get in the Strom ( 5.0), torch does not generate the CLICK event. So I have to go for UP event. In case of Storm(5.0), Touch and click are two different events. Up can generate when the user just do a touch on the control. When the user click on the control CLICK event will be generated. Hope that clarify you.

 

Regarding the 7.0, I never tested it yet as my current focus is 5.0 and 6.0 devices. Very soon I am going to add the 7.0 support too.

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

Re: Touch event on various different OS versions and devices

" torch does not generate the CLICK event"

It does according to my testing and I have a reasonable amount of code out there that relies on it doing so.

 

Even if it didn't, I would have thought a better 'test' would have been to check the device to see if the model was a 95xx rather than the OS level.  The Storm click screen is unlkely to be reused in a future device. 

 

In addition, I'm not sure why this wouldn't work either:

if ( message.getEvent() == TouchEvent.CLICK ||

     message.getEvent() == TouchEvent.UP) ) ....

 

Finally, I have reviewed some RIM supplied code and this is the testing that it does:

 

                switch( event ) {
               
                case TouchEvent.CLICK:
                case TouchEvent.DOWN:
                        // ....                        
                case TouchEvent.UNCLICK:
                case TouchEvent.UP:
                        // ....                        
                default:
                        return false;
                }

Perhaps this provides you with some code that will work correctly in all circumstances. 

 

 

Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: Touch event on various different OS versions and devices

Hey yo are right. Torch and Storm does support CLICK. I was facing this problem with one of the custom control. All other custom controls accept the CLICK on both STORM as well as TORCH. I have a custom button  created from the VerticalFieldManager. However it is accepting the CLICK on 9550 ( STORM), but it is not accepting the CLICK on TORCH. But if I use the UP, it is working fine.

 

Regarding using the UP or CLICK for the button click, it creates issue in STORM as the UP and CLICK are two different event. In case of STORM i cannot use UP as CLICKED. If user just touches the button, it just gets focussed. If you click only CLICK event gets generated.

 

How do I generalize this such that it works fine on STORM as well as TORCH?