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
Contributor
Posts: 18
Registered: ‎07-30-2010
My Device: Not Specified

Handle touch event and click enent

hi all I have add image on screen ,Is it possible to detect users touch event and click envent and check wheother point that user touch or click within particulare area if it is possible please give me some sample code thanks Osada
Trusted Contributor
Posts: 177
Registered: ‎03-02-2010
My Device: Not Specified

Re: Handle touch event and click event

[ Edited ]

Hi osadasliit, It is possible to detect touch and click event in bb 4.7 and above by using touchEvent. here i am posting sample code to detecting touch and clcik event.

 

 

protected boolean touchEvent(TouchEvent message)
    {
        // Retrieve the new x and y touch positions.               
        int x = message.getX(1);
        int y = message.getY(1);        
                                          
        int eventCode = message.getEvent();      
        
        if(eventCode == TouchEvent.DOWN)
        {                    
        }        
        
        if(eventCode == TouchEvent.MOVE)
        {             
          
        }
        else if(eventCode == TouchEvent.UP)
        {                   
           
        }        
        return true;       
    }

 

 

Regards,

Rishabh Jain

 

Developer
Posts: 203
Registered: ‎07-30-2009
My Device: Bold(9780),Curve(8520)
My Carrier: Vodafone

Re: Handle touch event and click enent

HI osada,

 

you can get the touch in 4.7 and above os please see the below code

 

BitmapField bitmapField = new BitmapField(){
                            protected boolean touchEvent(TouchEvent message) {
                                //your code here
                                return super.touchEvent(message);
                            }
                        };

 

 

Regards Tita

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Please press the kudos button on the left side to thank the user that helped you  and mark it solved as you get the proper solution.