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
Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

How can we handle multi touch in Torch(TouchGesture.PINCH)?

Hi,

 

How can we handle multi touch in Torch.

My requirement is expanding and compresing the MAP. Here i am using below code (putting dialog box for testing). but in any condition or any moment that dialog box is not executing.Please help me....

 

if(event == TouchEvent.GESTURE)
        {
            processGesture(touchEvent);
            return true;
        }
       
       return super.touchEvent(touchEvent);
    }
    private void processGesture(TouchEvent _event)
    {
        int pevent  = _event.getGesture().getEvent();
        if(pevent == TouchGesture.PINCH_UPDATE || pevent == TouchGesture.PINCH_BEGIN || pevent == TouchGesture.PINCH_END)
           {
               Dialog.alert("Hi");
           }
    }

 

 

Thanks in Advance.....

 

----------------------------------------------------------
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.

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: How can we handle multi touch in Torch(TouchGesture.PINCH)?

It might be one of the following:

 

1. Your if condition is not met - can be easily cheked with a debugger.

2. A UI issue - You would have to use one of the invoke functions (invokeLater or invokeAndWait) or to lock the eventLock: synchronized (Application.getEventLock{Dialog.alert("hi");})

 

E.

Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How can we handle multi touch in Torch(TouchGesture.PINCH)?

[ Edited ]

actually ichanged my code like below, but i got -1 is coming for x2 and y2.

 

 

InputSettings inputSetting = TouchscreenSettings.createEmptySet();
        inputSetting.set(TouchscreenSettings.DETECT_PINCH,1);
        if(this.getScreen() != null)
            this.getScreen().addInputSettings(inputSetting); 

 

 

int touchX1 = _event.getX(1);
        int touchX2 = _event.getX(2);
        int touchY1 = _event.getY(1);
        int touchY2 = _event.getY(2);
        int pevent  = _event.getGesture().getEvent();
        if(pevent == TouchGesture.PINCH_BEGIN )
        {
            Dialog.alert("PinchBegin.Touchx1:"+touchX1+" TouchX2:"+touchX2+" TouchY1:"+touchY1+" TouchY2:"+touchY2);
            
        }
        if(pevent == TouchGesture.PINCH_END)
        {
            Dialog.alert("PinchEnd");
        }

 

Thanks in advance...

----------------------------------------------------------
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.

Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: How can we handle multi touch in Torch(TouchGesture.PINCH)?

Hi,

 

  inputSetting.set(TouchscreenSettings.DETECT_PINCH,1);
        if(this.getScreen() != null)
            this.getScreen().addInputSettings(inputSetting);

This code is not suitable for jre 5.0

 

can any one help me....

thanks in advance...

----------------------------------------------------------
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.