Hi i have written a blackberry application with has been designed for the keyboard blackberry. Now i want to support touchscreen devices too. Any suggestion on how to support the touch screen device with the this library i looked around but could find any help full API. Any suggestion appreciated....
Where about in the roadmap is it ? When can we expect to have the updated library for that ?
In principle all you need is to redefine touchEvents in your application like following:
protected boolean touchEvent(TouchEvent event) {
int eventCode = event.getEvent();
switch (eventCode) {
case TouchEvent.CLICK:
mapComponent.pointerPressed(event.getX(1), event.getY(1));
break;
case TouchEvent.MOVE:
mapComponent.pointerDragged(event.getX(1), event.getY(1));
break;
case TouchEvent.UNCLICK:
mapComponent.pointerReleased(event.getX(1), event.getY(1));
break;
}
return false;
}
You can make it much more advanced with using also second finger click for zoom (for iPhone style zooming), caching more events etc.
Hi actaully the above code sample works in the Emulator / Simulator but it doesnt work on the real device. If you use the above code then it works perfectly on device and sim:
protected boolean touchEvent(TouchEvent event) {
int eventCode = event.getEvent();
switch (eventCode) {
case TouchEvent.CLICK:
System.out.println("TouchEvent.CLICK");
mapComponent.pointerPressed(event.getX(1), event.getY(1));
break;
case TouchEvent.DOWN:
System.out.println("TouchEvent.DOWN");
mapComponent.pointerPressed(event.getX(1), event.getY(1));
break;
case TouchEvent.MOVE:
System.out.println("TouchEvent.MOVE");
mapComponent.pointerDragged(event.getX(1), event.getY(1));
break;
case TouchEvent.UNCLICK:
System.out.println("TouchEvent.UNCLICK");
mapComponent.pointerReleased(event.getX(1), event.getY(1));
break;
case TouchEvent.UP:
System.out.println("TouchEvent.UP");
mapComponent.pointerReleased(event.getX(1), event.getY(1));
break;
}
return false;
}
Great, thank you!
Maybe also dual-touch zooming? You cannot use pointerDragged then, and should handle (memorize) click/unclick events and locations of both fingers (event.getX(1) and event.getX(2)), and then call zoomIn() and zoomOut() methods of the library.
The code is great and works, but then my next question will be how to handle place/element clicks with the touch features. Maybe there is some easy way to do it but I don´t see it right now.
Any help will be appreciated.
Emilio
BlackBerry 4.7 touchscreen API (for Storm) is not yet built in to the library, but it is in the roadmap. Meanwhile some have implemented it in the application level, and send moveMap() commands to map.
/JaakL